Skip to content

Flex / Grid Layout

Two layout primitives: Flex for one-dimensional layouts (row or column) and Grid for two-dimensional column grids. Both render as plain <div> elements using design-token spacing.

Terminal window
npx @a2ra/cli add layout
{
"type": "Grid",
"props": { "columns": 3, "gap": "md" },
"children": [
{ "type": "Card", "children": [{ "type": "Text", "children": "Item 1" }] },
{ "type": "Card", "children": [{ "type": "Text", "children": "Item 2" }] },
{ "type": "Card", "children": [{ "type": "Text", "children": "Item 3" }] }
]
}
PropTypeDescription
directionrow default
column
row-reverse
column-reverse
Flex direction
gapnone
xs
sm
md default
lg
xl
Gap between children
alignstart default
center
end
stretch
baseline
Cross-axis alignment
justifystart default
center
end
between
around
evenly
Main-axis distribution
wraptrue
false default
Allow children to wrap
childrennode[]Child nodes
PropTypeDescription
columnsnumber (1-12)Number of equal-width columns. Default: 2
gapnone
xs
sm
md default
lg
xl
Gap between cells
alignstart default
center
end
stretch
Row alignment
childrennode[]Child nodes
  • Flex and Grid render as plain <div> elements with no semantic meaning.
  • For form layouts, prefer Form over FlexForm wires up React Aria validation context.
  • Grid columns are always equal-width. For asymmetric layouts, nest multiple Flex nodes.