Layout Props
The rule
The prop set depends on what the element is:
Element | Accepts |
|---|---|
Layout: Box, Flex, Grid | spacing, size, position and overflow; Flex/Grid add their layout props |
Surface: Paper, Card | everything above plus bgColor, border, deep, color, font and motion |
Leaves: Button, Text, Label | spacing, plus the props each page lists |
Form controls, Image, Meter | grid placement only: area, alignSelf, justifySelf |
A layout container never paints. When you need a background, a border or elevation, use a Paper or Card.
How it works
Spacing. m, mt, mr, mb, ml, mx, my and the matching p* props, plus gap on flex and
grid containers. Values come from the spacing scale: zero, micro, xs, small, medium, large,
xl, xxl, giant — see Spacing & Dimensions.
p="small"
p="medium"
p="large"
Flex. flexDirection, alignItems, justifyContent, alignContent, wrap, flex, grow,
shrink, flexBasis, order, alignSelf, justifySelf. Alignment values are semantic (start,
center, between); the native names are accepted as aliases.
Size and position. width, height, min*, max* take tokens, numbers (px) or CSS strings.
position, top, right, bottom, left, zIndex, transform, overflow, display, cursor,
truncate and absoluteFill cover geometry.
Color. On surfaces and text, color and bgColor take theme tokens. A runtime CSS color (#hex,
oklch(), var(--x)) passes through untouched but skips the theme's contrast guarantees.
Responsive. Three channels, all mobile-first — the unprefixed prop is the base:
<Flex flexDirection="column" md_flexDirection="row" gap="small" md_gap="large">…</Flex>
<Flex viewportMedias={{ md: { flexDirection: 'row' } }}>…</Flex>
<Flex cq={{ md: { flexDirection: 'row' } }}>…</Flex>The sm_/md_/lg_/xl_ prefixes and viewportMedias respond to the viewport; cq responds to the
width of the slot. See Container Queries.
Pitfalls
- Expecting a row from a bare
Flex→ itsflexDirectiondefaults tocolumn; declarerow. - Centering vertically with
alignItemson a column → on a column the main axis is vertical; usejustifyContent="center". - Mixed type sizes on one line looking crooked with
alignItems="center"→ usealignItems="baseline".