PRIMITIVES

Box

Polymorphic flex primitive. Use it whenever you need a flex container with type-checked direction, gap, alignment and justification — and the option to render as any HTML element via as.

Import

import { Box } from 'damo-ui'

Row layout

OneTwoThree
1<Box gap={3} align="center">
2  <span>One</span>
3  <span>Two</span>
4  <span>Three</span>
5</Box>

Column layout

TopMiddleBottom
1<Box direction="column" gap={2}>
2  <span>Top</span>
3  <span>Middle</span>
4  <span>Bottom</span>
5</Box>

Polymorphic — render as any element

Pass as to render Box as a different tag while keeping the layout utilities. Useful for landmark elements (<section>, <header>, <aside>) or to forward to a Next Link.

1<Box as="section" direction="column" gap={4}>
2  <h2>Heading</h2>
3  <p>Paragraph</p>
4</Box>

Props

Box props
PropTypeDefaultDescription
asElementType'div'Polymorphic element. Pass any HTML tag or component (section, header, aside, Link, …) and Box keeps its layout utilities while delegating semantics to the chosen element.
direction'row' | 'row-reverse' | 'column' | 'column-reverse''row'Sets flex-direction.
gap0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 200Tailwind spacing step applied to the flex container gap.
align'start' | 'center' | 'end' | 'stretch' | 'baseline''stretch'align-items.
justify'start' | 'center' | 'end' | 'between' | 'around' | 'evenly''start'justify-content.
wrap'wrap' | 'nowrap' | 'wrap-reverse''nowrap'flex-wrap.
inlinebooleanfalseSwitch to inline-flex when the box must sit inline with text.
classNamestringTailwind classes are merged on top of the variant defaults.

When to use it

  • Most flex layouts in product code — replaces ad-hoc flex flex-row gap-3 items-center stacks.
  • For wider, page-level layouts with a max-width, prefer Container.
  • When the children must split into named regions, use a dedicated layout component such as AppShell.
Box — Damo UI