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
asprop - 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
| Component | Purpose | Built on |
|---|---|---|
| Box | Universal container | - |
| Stack | Vertical/horizontal layout | Box + flex logic |
| Inline | Horizontal layout | Box + flex(row) |
| Center | Center alignment | Box + centering |
| Card | Card-styled container | Box + card styles |
All components inherit Box's capabilities while adding specific behavior or styles.
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
as | ElementType | 'div' | No | Element to render, for example section or ul |
children | ReactNode | - | No | Content |
Usage
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).
Related Components
- Stack — Vertical or horizontal layout with consistent spacing
- Inline — Horizontal layout (row-direction optimized version of Stack)
- Center — Center alignment
- Card — Card-styled container