Flex

A component for creating flex layouts.

Use these props to create flex layouts.

PropTypeDefault
displayResponsive<"none" | "inline-flex" | "flex">"flex"
directionResponsive<"row" | "column" | "row-reverse" | "column-reverse">
alignResponsive<"start" | "center" | "end" | "baseline" | "stretch">
justifyResponsive<"start" | "center" | "end" | "between">"start"
wrapResponsive<"nowrap" | "wrap" | "wrap-reverse">
gapResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>

The following props are shared between Box, Container, Flex, Grid, and Section layout components.

PropTypeDefault
positionResponsive<"static" | "relative" | "absolute" | "fixed" | "sticky">
insetResponsive<Union<string, "-9" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
topResponsive<Union<string, "-9" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
bottomResponsive<Union<string, "-9" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
leftResponsive<Union<string, "-9" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
rightResponsive<Union<string, "-9" | "-8" | "-7" | "-6" | "-5" | "-4" | "-3" | "-2" | "-1" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
pResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
pyResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
pxResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
ptResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
pbResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
plResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
prResponsive<Union<string, "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9">>
widthResponsive<string>
minWidthResponsive<string>
maxWidthResponsive<string>
heightResponsive<string>
minHeightResponsive<string>
maxHeightResponsive<string>
gridColumnResponsive<string>
gridColumnStartResponsive<string>
gridColumnEndResponsive<string>
gridRowResponsive<string>
gridRowStartResponsive<string>
gridRowEndResponsive<string>
flexShrinkResponsive<Union<string, "0" | "1">>
flexGrowResponsive<Union<string, "0" | "1">>

This component is based on the div element and also supports common margin props m, mx, my, ml, mr, mt, mb. View source

Use the direction prop to set the flex direction. You can change it across breakpoints using the object syntax.

Use the align prop to set the alignment of the flex items across the flex direction. Use the justify prop to control how space is distributed between items along the flex direction.

You can change the values across breakpoints using the object syntax.

We do not plan to implement props for align-self and justify-self. UI code tends to be easier to understand and debug when parent components control the layout. Nesting Flex elements is the way to go when you need different alignment within one container.

Elixir SDKNew

Use the wrap prop to control whether the flex items wrap to the next line. You can change the wrapping behaviour across breakpoints using the object syntax.

Use the gap prop to set spacing between flex items. You can change the gap across breakpoints using the object syntax.

In the spirit of lifting layout responsibilities onto parent components, consider spacing elements using Flex with the gap prop instead of margins on the individual items.

IntroductionWhat you’ll buildBefore getting startedAPI object definitions