flutter-view
Search…
CSS style properties
A list of all the supported CSS style like shortcuts you can use as properties in your pug tags. These will then transform themselves into the appropriate Dart code.

alignment

Describes where the content of a child should be positioned. Eg: text inside of a container.
Maps to Flutter Alignment values in camelcase.
Valid values:
  • bottom-center: The center point along the bottom edge
  • bottom-left: The bottom left corner
  • bottom-right: The bottom right corner
  • center: The center point, both horizontally and vertically
  • center-left: The center point along the left edge
  • center-right: The center point along the right edge
  • top-center: The center point along the top edge
  • top-left: The top left corner
  • top-right: The top right corner
Example:
Pug
Dart
1
container(width=500 height=400)
2
.greeting(alignment='center-right')
3
| Hello, I am positioned at the right!
4
Copied!
1
Container(
2
child:
3
Container(
4
child: Text(
5
'Hello, I am positioned at the right!',
6
),
7
alignment: Alignment.centerRight,
8
),
9
width: 500,
10
height: 400,
11
)
Copied!

fit

Describes how a box should be inscribed into another box. Used for the FittedBox Flutter container. Use the background-size style property instead if you want to apply a sizing to a background-image.
Maps to Flutter BoxFit values in camelcase.
Valid values:
  • contain: As large as possible while still containing the source entirely within the target box
  • cover: As small as possible while still covering the entire target box.
  • fill: Fill the target box by distorting the source's aspect ratio.
  • fill-height: Make sure the full height of the source is shown, regardless of whether this means the source overflows the target box horizontally.
  • fill-width: Make sure the full width of the source is shown, regardless of whether this means the source overflows the target box vertically.
  • none: Align the source within the target box (by default, centering) and discard any portions of the source that lie outside the box. The source image is not resized.
  • scale-down: Align the source within the target box (by default, centering) and, if necessary, scale the source down to ensure that the source fits within the box. This is the same as contain if that would shrink the image, otherwise it is the same as none.
See the Flutter BoxFit documentation for more information on these options.
Example:
Pug
Dart
1
.cover-image(
2
background-image="asset('images/background.jpg')"
3
fit='cover')
4
Copied!
1
Container(
2
decoration: BoxDecoration(
3
image: DecorationImage(
4
image: AssetImage(
5
'images/background.jpg',
6
),
7
fit: BoxFit.cover,
8
),
9
)
Copied!

shape

Describes how the container should be shaped.
Maps to Flutter BoxShape values in camelcase. Creates a Flutter BoxDecoration with the shape property set to to the value you pass.
Valid values:
  • circle: A circle centered in the middle of the box into which the Border or BoxDecoration is painted. The diameter of the circle is the shortest dimension of the box, either the width or the height, such that the circle touches the edges of the box.
  • rectangle: An axis-aligned, 2D rectangle. May have rounded corners (described by a BorderRadius). The edges of the rectangle will match the edges of the box into which the Border or BoxDecoration is painted.
Example:
Pug
Dart
1
.cover-image(
2
background-image="asset('images/background.jpg')"
3
shape='circle')
4
Copied!
1
Container(
2
decoration: BoxDecoration(
3
image: DecorationImage(
4
image: ExactAssetImage(
5
'images/background.jpg',
6
),
7
),
8
shape: BoxShape.circle,
9
),
10
)
Copied!

padding

Creates a Flutter padding property using EdgeInsets.only().
There are several padding properties you can use:
  • padding-left: padding on the left side only
  • padding-right: padding on the right side only
  • padding-top: padding on the top side only
  • padding-bottom: padding on the bottom side only
  • padding: padding for all sides
These properties take values according to the CSS specification, with these exceptions:
  • only direct values (numbers) are accepted
  • no support for percentages
Examples of valid values:
1
padding-left: 10 // EdgeInsets.only(left: 10)
2
padding-top: 50 // EdgeInsets.only(top: 50)
3
padding: 10 // EdgeInsets.only(top: 10, left: 10, bottom: 10, right: 10)
4
padding: 5.5 7 // EdgeInsets.only(top: 5.5, left: 7, bottom: 5.5, right: 7)
Copied!
Example:
Pug
Dart
1
.greeting(padding=10) Hello world!
Copied!
1
Container(
2
child: Text(
3
'Hello world!',
4
),
5
padding: EdgeInsets.only(top: 10, right: 10, bottom: 10, left: 10),
6
)
Copied!

margin

Creates a Flutter margin property using EdgeInsets.only().
There are several margin properties you can use:
  • margin-left: margin on the left side only
  • margin-right: margin on the right side only
  • margin-top: margin on the top side only
  • margin-bottom: margin on the bottom side only
  • margin: margin for all sides
These properties take values according to the CSS specification, with these exceptions:
  • only direct values (numbers) are accepted
  • no support for percentages
Examples of valid values:
1
margin-left: 10 // EdgeInsets.only(left: 10)
2
margin-top: 50 // EdgeInsets.only(top: 50)
3
margin: 10 // EdgeInsets.only(top: 10, left: 10, bottom: 10, right: 10)
4
margin: 5.5 7 // EdgeInsets.only(top: 5.5, left: 7, bottom: 5.5, right: 7)
Copied!
Example:
Pug
Dart
1
.greeting(margin=10) Hello world!
Copied!
1
Container(
2
child: Text(
3
'Hello world!',
4
),
5
margin: EdgeInsets.only(top: 10, right: 10, bottom: 10, left: 10),
6
)
Copied!

border-radius

Decorates a container with rounded borders.
Creates a Flutter BoxDecoration with borderRadius set using BorderRadius.only(). The values passed to BorderRadius.only for each corner are values of Radius.circular().
The border-radius property takes values according to the CSS specification, with these exceptions:
  • only direct values (numbers) are accepted
  • no support for percentages
Examples of valid values:
1
border-radius: 5 // BorderRadius.only(topLeft: Radius.circular(5), topRight: Radius.circular(5), bottomRight: Radius.circular(5), bottomLeft: Radius.circular(5))
2
border-radius: 2 5 2.5 7 // BorderRadius.only(topLeft: Radius.circular(2), topRight: Radius.circular(5), bottomRight: Radius.circular(2.5), bottomLeft: Radius.circular(7))
3
border-radius: 5 4 // BorderRadius.only(topLeft: Radius.circular(5), topRight: Radius.circular(4), bottomRight: Radius.circular(5), bottomLeft: Radius.circular(4))
Copied!
Example:
Pug
Dart
1
.greeting(border-radius=4 background-color='grey') Hello world!
Copied!
1
Container( // project://lib/pages/homepage/homepage.pug#8,5
2
child: Text(
3
'Hello world!',
4
),
5
decoration: BoxDecoration(
6
color: Colors.grey,
7
borderRadius: BorderRadius.only(topLeft: Radius.circular(5), topRight: Radius.circular(5), bottomRight: Radius.circular(5), bottomLeft: Radius.circular(5)),
8
),
9
)
Copied!

border

Creates a Flutter Border widget property using EdgeInsets.only().
Creates a Flutter BoxDecoration with border set using Border(). The values passed to Border() for each side are values of BorderSide, with an optional width, style and color.
There are several border properties you can use:
  • border-left: style of the left border
  • border-right: style of the right border
  • border-top: style of the top border
  • border-bottom: style of the bottom border
  • border: style for all border sides
  • border-style: line style for all border sides
  • border-width: width of all border sides
  • border-color: color of all border sides
These properties take values according to the CSS specification, with these exceptions:
  • for styles, only solid and none are accepted
  • width must be a number
  • color must be a name (this is a bug, will be fixed soon)
  • the border property only allows a single style for all, not a style per side
Examples of valid values:
1
border-left: 1 solid red
2
border-width: 3.3
3
border: none
4
border: 5.5 blue
Copied!
Example:
Pug
Dart
1
.greeting(border-top='1.4 red' border-bottom='0.5 green') Hello world!
Copied!
1
Container(
2
child: Text(
3
'Hello world!',
4
),
5
decoration: BoxDecoration(
6
border: Border(
7
top: BorderSide(
8
width: 1.4,
9
color: Colors.red,
10
),
11
bottom: BorderSide(
12
width: 0.5,
13
color: Colors.green,
14
),
15
),
16
),
17
)
Copied!

box-shadow

Adds shadows to containers.
Creates a Flutter BoxDecoration with the boxShadow property set using BoxShadow.
It suppors multiple passed box shadows, separated by a comma.
A single box shadow can have 2, 3 or 4 or 5 properties: offset-x, offset-y, and optionally blur-radius offset-radius and color.
These properties take values according to the CSS specification, with these exceptions:
  • values must be numbers
  • colors not yet supported (coming soon)
  • no support for the inset keyword
Examples of valid values:
1
box-shadow: 2 3 // single shadow with offset-x: 3, offset-y: 3
2
box-shadow: 2 2 5 // single shadow with offset-x: 2, offset-y: 2 and blur: 5
3
box-shadow: 4 3 6 7 // single grey shadow with blur: 6 and offset-radius: 7
4
box-shadow: 2 3, 3 4 9 4 // two box shadows example
Copied!
Example:
Pug
Dart
1
.greeting(box-shadow='2 3 5 7, -5 -2') Hello world!
Copied!
1
Container(
2
child: Text(
3
'Hello world!',
4
),
5
decoration: BoxDecoration(
6
boxShadow: [
7
BoxShadow(
8
offset: Offset(2.00, 3.00),
9
blurRadius: 5.00,
10
spreadRadius: 7.00,
11
),
12
BoxShadow(
13
offset: Offset(-5.00, -2.00),
14
)
15
],
16
),
17
)
Copied!

background-image

Sets a background image to containers.
Creates a Flutter BoxDecoration with the image property set using either NetworkImage or ExactAssetImage.
The background-image property can have one of two values:
  • url("<image-url>") : creates a NetworkImage for the given url
  • asset("<asset-name>"): uses an ExactAssetImage for the given name
Examples of valid values:
1
background-image: asset('images/background.jpg')
2
background-image: url('http://some/image/url.png')
Copied!
Example:
Pug
Dart
1
.cover-image(background-image="asset('images/background.jpg')")
Copied!
1
Container(
2
decoration: BoxDecoration(
3
image: DecorationImage(
4
image: ExactAssetImage(
5
'images/background.jpg',
6
),
7
),
8
),
9
)
Copied!

​background-color

Sets a background color to containers.
Creates a Flutter BoxDecoration with the color property set to the value you pass as a Color.
See the color property on valid values.
Example:
Pug
Dart
1
.redbox(width=200 height=200 background-color="red")
Copied!
1
Container(
2
decoration: BoxDecoration(
3
color: Colors.red,
4
),
5
width: 200,
6
height: 200,
7
)
Copied!

background-repeat

Sets how background images of a container should be repeated. Usually used together with background-image.
Creates a Flutter BoxDecoration with the repeat property of the image set to the value you pass.
Maps to Flutter ImageRepeat values in camelcase.
Valid values:
  • no-repeat: Leave uncovered portions of the box transparent
  • repeat: Repeat the image in both the x and y directions until the box is filled.
  • repeat-x: Repeat the image in the x direction until the box is filled horizontally.
  • repeat-y: Repeat the image in the y direction until the box is filled vertically.
Example:
Pug
Dart
1
.cover-image(
2
background-image="asset('images/background.jpg')"
3
background-repeat='no-repeat')
Copied!
1
Container( // project://lib/pages/homepage/homepage.pug#8,5
2
decoration: BoxDecoration(
3
image: DecorationImage(
4
image: ExactAssetImage(
5
'images/background.jpg',
6
),
7
repeat: ImageRepeat.noRepeat,
8
),
9
),
10
)
Copied!

background-size

Sets how background images of a container should be fitted in the container. Usually used together with background-image.
It does so by setting the fit property of the ImageDecoration that was created for the background-image.
See the fit property above for valid values and more information.
Example:
Pug
Dart
1
.cover-image(
2
background-image="asset('images/background.jpg')"
3
background-fit='cover')
Copied!
1
Container(
2
decoration: BoxDecoration(
3
image: DecorationImage(
4
image: ExactAssetImage(
5
'images/background.jpg',
6
),
7
fit: BoxFit.cover,
8
),
9
),
10
)
Copied!

main-axis-alignment

Controls how a row or column aligns its children on the main axis. See the Flutter layout documentation for more information.
Maps to Flutter MainAxisAlignment enum values in camelcase.
Valid values:
  • start: Place the children as close to the start of the main axis as possible
  • end: Place the children as close to the end of the main axis as possible
  • center: Place the children as close to the middle of the main axis as possible
  • space-around: Place the free space evenly between the children as well as half of that space before and after the first and last child
  • space-between: Place the free space evenly between the children
  • space-evenly: Place the free space evenly between the children as well as before and after the first and last child
Example:
Pug
Dart
1
row(main-axis-alignment="space-evenly")
2
.entry We
3
.entry Are
4
.entry Spaced
5
.entry Evenly
Copied!
1
Row(
2
children: [
3
Container(
4
child: Text(
5
'We',
6
),
7
),
8
Container(
9
child: Text(
10
'Are',
11
),
12
),
13
Container(
14
child: Text(
15
'Spaced',
16
),
17
),
18
Container(
19
child: Text(
20
'Evenly',
21
),
22
)
23
],
24
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
25
)
Copied!

cross-axis-alignment

Controls how a row or column aligns its children on the cross axis. See the Flutter layout documentation for more information.
Maps to Flutter CrossAxisAlignment enum values in camelcase.
Valid values:
  • start: Place the children with their start edge aligned with the start side of the cross axis
  • end: Place the children as close to the end of the cross axis as possible
  • center: Place the children so that their centers align with the middle of the cross axis
  • baseline: Place the children along the cross axis such that their baselines match
  • stretch: Require the children to fill the cross axis
Example:
Pug
Dart
1
column(cross-axis-alignment="center")
2
.entry We
3
.entry Are
4
.entry Centered
Copied!
1
Column(
2
children: [
3
Container(
4
child: Text(
5
'We',
6
),
7
),
8
Container(
9
child: Text(
10
'Are',
11
),
12
),
13
Container(
14
child: Text(
15
'Centered',
16
),
17
)
18
],
19
crossAxisAlignment: CrossAxisAlignment.center,
20
),
Copied!

main-axis-size

Controls how a row or column to deals with left-over free space in the main axis. See the Flutter layout documentation for more information.
Maps to Flutter MainAxisSize enum values in camelcase.
Valid values:
  • min: Minimize the amount of free space along the main axis, subject to the incoming layout constraints
  • max: Maximize the amount of free space along the main axis, subject to the incoming layout constraints
Example:
Pug
Dart
1
column(main-axis-size="max")
2
.entry Some entry, left over space is maximized
Copied!
1
Column(
2
children: [
3
4
//-- ENTRY ----------------------------------------------------------
5
Container( // project://lib/pages/homepage/homepage.pug#14,6
6
child: Text(
7
'Some entry, left over space is maximized',
8
),
9
)
10
],
11
mainAxisSize: MainAxisSize.max,
12
)
Copied!

color, ...-color

Assigns a Color to a property. It works on any property either named color, or ending with -color.
When a color is set on a Container, it will set the text color, much like you would set a color CSS property on a DIV in HTML. It does so by wrapping the container with DefaultTextStyle.merge and setting the text color in the TextStyle that is passed.
Valid values:
  • Any expression that evalutes to a Color. :color='Colors.red'
  • A dash-cased color name from Colors. color='deep-orange'
  • A dash-cased color name from Colors with a weight. color='deep-orange[400]'
  • A hex color ala CSS. color='#FF3499'
  • A hex color ala CSS with preceding transparency. color='#80FF3499'
Examples:
Using Pug
Using CSS
generated Dart
1
.red-text-container(color='red') This text is red
2
.red-container(:background-color='Colors.red')
3
.orange-container(background-color='deep-orange')
4
.green-container(background-color='green[300]')
5
.blue-container(background-color='#00F')
6
.blue-container2(background-color='#0000FF')
Copied!
1
.red-text-container
2
color: red
3
.red-container
4
background-color: ':Colors.red'
5
.orange-container
6
background-color: deep-orange
7
.green-container
8
background-color: green[300]
9
.blue-container
10
background-color: #00F
11
.blue-container2
12
background-color: #0000FF
Copied!
1
Column(
2
children: [
3
DefaultTextStyle.merge(
4
child:
5
//-- RED-TEXT-CONTAINER ----------------------------------------------------------
6
Container(
7
child: Text(
8
'This text is red',
9
),
10
),
11
style: TextStyle(
12
color: Colors.red,
13
),
14
),
15
16
//-- RED-CONTAINER ----------------------------------------------------------
17
Container(
18
decoration: BoxDecoration(
19
color: Colors.red,
20
),
21
),
22
23
//-- ORANGE-CONTAINER ----------------------------------------------------------
24
Container(
25
decoration: BoxDecoration(
26
color: Colors.deepOrange,
27
),
28
),
29
30
//-- GREEN-CONTAINER ----------------------------------------------------------
31
Container(
32
decoration: BoxDecoration(
33
color: Colors.green.shade300,
34
),
35
),
36
37
//-- BLUE-CONTAINER ----------------------------------------------------------
38
Container(
39
decoration: BoxDecoration(
40
color: Color(0xFF0000FF),
41
),
42
),
43
44
//-- BLUE-CONTAINER2 ----------------------------------------------------------
45
Container(
46
decoration: BoxDecoration(
47
color: Color(0xFF0000FF),
48
),
49
)
50
],
51
)
Copied!

font-size

Sets the font size of text in the container and all its children. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the font size in the TextStyle that is passed.
Allowed values are ints, doubles and theme font sizes.
Example:
Pug
Dart
1
.test(font-size=12.5) Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child: Container(
3
child: Text(
4
'Welcome!',
5
),
6
),
7
style: TextStyle(
8
fontSize: 12.5,
9
),
10
)
Copied!

font-weight

Sets the font weight of text in the container and all its children. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the font weight in the TextStyle that is passed.
Maps to Flutter FontWeight enum values in camelcase.
Valid values:
  • normal: The default font weight
  • bold: A commonly used font weight that is heavier than normal
  • w100: Thin, the least thick
  • w200: Extra light
  • w300: Light
  • w400: Normal / regular / plain
  • w500: Medium
  • w600: Semi bold
  • w700: Bold
  • w800: Extra bold
  • w900: Black, the most thick
Note: Instead of passing w100, you may also pass 100, etc.
Example:
Pug
Dart
1
.test(font-weight='bold') Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'Welcome!',
6
),
7
),
8
style: TextStyle(
9
fontWeight: FontWeight.bold,
10
),
11
)
Copied!

font-family

Sets the font family of text in the container and all its children. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the font family in the TextStyle that is passed.
Value must be a string.
Example:
Pug
Dart
1
.test(font-size='Arial') Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child: Container(
3
child: Text(
4
'Welcome!',
5
),
6
),
7
style: TextStyle(
8
fontFamily: 'Arial',
9
),
10
)
Copied!

font-style

Sets the font style of text in the container and all its children. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the font style in the TextStyle that is passed.
Maps to Flutter FontStyle enum values in camelcase.
Valid values:
  • normal: The default font style
  • italic: Use glyphs designed for slanting
Example:
Pug
Dart
1
.test(font-style='italic') Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'Welcome!',
6
),
7
),
8
style: TextStyle(
9
fontStyle: FontStyle.italic,
10
),
11
)
Copied!

letter-spacing

The amount of space (in logical pixels) to add between each letter. A negative value can be used to bring the letters closer. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the letter spacing in the TextStyle that is passed.
Valid values are ints and doubles.
Example:
Pug
Dart
1
.test(letter-spacing=3) This text gets spaced out
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'This text gets spaced out',
6
),
7
),
8
style: TextStyle(
9
letterSpacing: 3,
10
),
11
)
Copied!

line-height

Sets the line height text in the container and all its children. Only works on Containers.
It does so by wrapping the container with DefaultTextStyle.merge and setting the line height in the TextStyle that is passed.
Valid values are ints and doubles.
Example:
Pug
Dart
1
.test(line-height=20) Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'Welcome!',
6
),
7
),
8
style: TextStyle(
9
height: 20,
10
),
11
)
Copied!

text-decoration

A linear decoration to draw near the text.
It does so by wrapping the container with DefaultTextStyle.merge and setting the textDecoration in the TextStyle that is passed.
Maps to Flutter TextDecoration enum values in camelcase.
Valid values:
  • none: Do not draw a decoration
  • underline: Draw a line underneath each line of text
  • overline: Draw a line above each line of text
  • line-through: Draw a line through each line of text
Example:
Pug
Dart
1
.test(text-decoration='underline') Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'Welcome!',
6
),
7
),
8
style: TextStyle(
9
textDecoration: TextDecoration.underline,
10
),
11
)
Copied!

text-decoration-color

The color of the text decoration you have set.
It does so by wrapping the container with DefaultTextStyle.merge and setting the decorationColor in the TextStyle that is passed.
The value must be a valid color property value.
Example:
Pug
Dart
1
.test(
2
text-decoration='underline'
3
text-decoration-color='red')
4
| Hello world!
Copied!
1
DefaultTextStyle.merge(
2
child: Container(
3
child: Text(
4
'Hello world!',
5
),
6
),
7
style: TextStyle(
8
decoration: TextDecoration.underline,
9
decorationColor: Colors.red,
10
),
11
)
Copied!

text-decoration-style

The style in which to draw a text decoration.
It does so by wrapping the container with DefaultTextStyle.merge and setting the decorationStyle in the TextStyle that is passed.
Maps to Flutter TextDecorationStyle enum values in camelcase.
Valid values:
  • solid: Draw a solid line
  • double: Draw two lines
  • dotted: Draw a dotted line
  • dashed: Draw a dashed line
  • wavy: Draw a sinusoidal line
Example:
Pug
Dart
1
.test(
2
text-decoration='underline'
3
text-decoration-style='wavy')
4
| Hello world!
Copied!
1
DefaultTextStyle.merge(
2
child: Container( // project://lib/pages/homepage/homepage.pug#8,5
3
child: Text(
4
'Hello world!',
5
),
6
),
7
style: TextStyle(
8
decoration: TextDecoration.underline,
9
decorationStyle: TextDecorationStyle.wavy,
10
),
11
)
Copied!

word-spacing

Sets the space between words in a text.
It does so by wrapping the container with DefaultTextStyle.merge and setting the wordSpacing in the TextStyle that is passed.
Valid values are ints and doubles.
Example:
Pug
Dart
1
.test(word-spacing=5.3) Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(
4
child: Text(
5
'Welcome!',
6
),
7
),
8
style: TextStyle(
9
wordSpacing: 5.3,
10
),
11
)
Copied!

text-align

Whether and how to align text horizontally.
It does so by wrapping the container with DefaultTextStyle.merge and setting the textAlign in the TextStyle that is passed.
Maps to Flutter TextAlign enum values in camelcase.
Valid values:
  • start: Align the text on the leading edge of the container.
  • end: Align the text on the trailing edge of the container.
  • left: Align the text on the left edge of the container.
  • right: Align the text on the right edge of the container.
  • center: Align the text in the center of the container.
  • justify: Stretch lines of text that end with a soft line break to fill the width of the container.
Example:
Pug
Dart
1
.test(text-align='center') Welcome!
Copied!
1
DefaultTextStyle.merge(
2
child:
3
Container(