Box
The escape hatch: a raw host element with a className, still checked for
tokens-only classes. Box renders the chosen {@link LayoutElement} with no
layout opinions of its own (no margin, width, or padding, unlike Container),
so it suits decorative wrappers that a styled primitive would visually break. Reach for it only when no styled primitive fits; the
className you pass is governed by the same tokens-only scan as everything
else. RSC-safe.
Usage
Best practices
Boxrenders the chosen element with no layout opinions (no margin/width/padding, unlikeContainer); use it as a neutral wrapper when a styled primitive would interfere.Use
as="span"for a decorative inline wrapper; reach forBoxonly when no styled primitive fits - itsclassNameis still checked for tokens-only classes.asandrenderare mutually exclusive (renderwins, dev-warned);asdraws from the closed layout vocabulary.Use
asto change the element (a tag); userenderonly to swap in a component (e.g. a router Link). Neverrender={<Box as=…/>}- passasdirectly.
Props
Also exports
- interface
BoxProps
Composition
Used by