Layout

Layout Variants

💡

You can always modify the existing typography variants or add new ones by editing the components/layout/variants.ts file.

Layout components

Box, Flex and Grid are foundational elements you'll use to construct layouts. Box provides block-level spacing and sizing, while Flex and Grid let you create flexible columns, rows and grids.

<Grid columns="3" gap="3">
  <Flex direction="column" gap="3">
    <Box height="5">
      <DecorativeBox />
    </Box>
    <Box height="7">
      <DecorativeBox />
    </Box>
    <Box height="9">
      <DecorativeBox />
    </Box>
  </Flex>
 
  <Flex direction="column" gap="3">
    <Box grow="1">
      <DecorativeBox />
    </Box>
    <Box height="6">
      <DecorativeBox />
    </Box>
  </Flex>
</Grid>

Container and Section are used for page level layout and allow you to contain the max width of content or apply consistent vertical spacing between sections.

All layout components share a common set of props without default values:

PropType
penum
pxenum
pyenum
ptenum
prenum
pbenum
plenum
menum
mxenum
myenum
mtenum
mrenum
mbenum
mlenum
positionstatic | relative | absolute | fixed | sticky
widthenum
heightenum
borderenum
roundedenum

Margin props

Shorthand utilities for applying margin to any side of an element, useful when you need to apply space between elements. Margin props are available on components that render a node.

<Button mr="3" variant="soft">Cancel</Button>
<Button>Save changes</Button>
PropTypeOptions
menum0 | 2 | 4 | 8
mxenumauto | 0 | 2 | 4 | 8
myenumauto | 0 | 2 | 4 | 8
mtenumauto | 0 | 2 | 4 | 8
mrenumauto | 0 | 2 | 4 | 8
mbenumauto | 0 | 2 | 4 | 8
mlenumauto | 0 | 2 | 4 | 8

Padding props

Shorthand utilities for applying padding to any side of an element. Padding props are available on components that render a node.

<div pr="3">
  <Text variant="heading">Edit your profile</Text>
</div>
PropTypeOptions
penum0 | 2 | 4 | 8
pxenum0 | 2 | 4 | 8
pyenum0 | 2 | 4 | 8
ptenum0 | 2 | 4 | 8
prenum0 | 2 | 4 | 8
pbenum0 | 2 | 4 | 8
plenum0 | 2 | 4 | 8

Display props

Shorthand utilities for applying display to an element. Display props are available on components that render a node.

<Box display="flex" justifyContent="center">
  <Text variant="heading">Edit your profile</Text>
</Box>
PropTypeOptions
displayenumblock | flex | inline-block | inline-flex | inline | none

Position props

Shorthand utilities for applying position to an element. Position props are available on components that render a node.

<Box position="relative">
  <Box position="absolute" top="0" right="0">
    <Button variant="soft">Cancel</Button>
  </Box>
  <Text variant="heading">Edit your profile</Text>
</Box>
PropTypeOptions
positionenumstatic | relative | absolute | fixed | sticky