Components

Box

Styling-capable universal container — foundation building block for all components

Overview

Box is the foundation building block of the design system. It provides styling capabilities to HTML elements while maintaining maximum flexibility.

Box is: a stylable <div> that can render as any HTML element.

  • Minimal — No built-in layout logic or predefined styles
  • Flexible — Render as any HTML element via the as prop
  • Universal — Base layer for all other components (Stack, Card, Button, etc.)
  • Unopinionated — Everything is controlled by the user

When to Use

Use Box when:

  • You need a simple wrapper or container
  • You need semantic HTML (as="section", as="article", as="nav")
  • You're building a custom component from scratch
  • You need maximum control with minimal abstraction

Consider alternatives when:

  • You need vertical/horizontal stacking → Use Stack or Inline
  • You need something people click → Use Button or IconButton. Box has no hover or pressed styles; an interactive element's states belong to its component
  • You need center alignment → Use Center
  • You're building a card → Use the Card component
  • You need button behavior → Use the Button component

If there's a specialized component for your use case, use it. Box is for everything else.

Box vs Other Components

ComponentPurposeBuilt on
BoxUniversal container-
StackVertical/horizontal layoutBox + flex logic
InlineHorizontal layoutBox + flex(row)
CenterCenter alignmentBox + centering
CardCard-styled containerBox + card styles

All components inherit Box's capabilities while adding specific behavior or styles.

Props

PropTypeDefaultRequiredDescription
asElementType'div'NoElement to render, for example section or ul
childrenReactNode-NoContent

Usage

Done

Style Priority

When the same property is set in several places, the inline style prop wins over style props (width, opacity), which win over token props (p, bg).

Token props only: p="400" bg="backgroundTagBlue"

The style prop wins over bg: the background is red, not gray

  • Stack — Vertical or horizontal layout with consistent spacing
  • Inline — Horizontal layout (row-direction optimized version of Stack)
  • Center — Center alignment
  • Card — Card-styled container