Box
Generic layout wrapper for spacing, sizing, and surface styling on a single node.
Box is a theme-aware container for one element—like a <div> with optional token-based padding, margin, width, and extra CSS. Use it when a single wrapper needs spacing or sizing without distributing gaps between siblings. foreground sets theme text color — not the CSS color shorthand prop. For even gaps between children, prefer Stack or Flex.
- One wrapper needs padding, margin, max-width, or surface styling
- A card-like region without the full Material API
- Custom layout chrome where Stack / Flex are too opinionated
- Put content in the default slot.
- Set typed
padding,margin,background,radius, and related token props. - Pass additional rules through
stylewhen you need escape-hatch CSS. - Add utility classes through
classwhen needed.
A bordered box with sample text—the quickest way to see the container bounds.
The padding prop adds inner space without extra wrapper markup.
The margin prop offsets the box from surrounding layout—visible against a tinted backdrop.
Constrain width on forms, side panels, and compact callouts.
Combine typed surface props for a subtle raised panel.