Box
The basic surface to put content on. It is the plainest sheet in the library: it groups content and lifts it off the page background.
import { Box } from 'neba';
<Box>Content</Box>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variantshared | 'solid' | 'outline' | 'text' | 'outline' | Weight of the surface. The sheet is never dyed: solid and outline differ in opacity and hairline |
| sizeshared | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Corner radius and padding. Never a height, never the type scale |
| colorshared | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | Semantic colour role. The surface is white, so it reaches the hairline only: invisible on solid, which has no border |
| densityshared | 'default' | 'compact' | 'default' | Padding only: never the height, never the type scale |
| elevationshared | 0 | 1 | 2 | 3 | 0 | Drop shadow depth. Ignored when variant is text |
| padded | boolean | true | Inner padding. Turn it off for full-bleed content: an image, a table |
| render | useRender.RenderProp | — | Renders something other than a div. Base UI's own escape hatch |
| children | ReactNode | — | What the box holds |
| transitionshared | NebaTransition | — | An entrance animation, run once on mount (transition="fade"). Wrap it in an Animate* component for a trigger or a replay |
Every native <div> attribute passes through, color excepted.
When structure is needed (a title, a footer, dividers), use Card, which is a Box with those sections laid out on it.
Examples
variant
None of the three weights flood the sheet with colour, because what a Box holds is content that arrives with colours of its own. What separates solid from outline is the sheet's opacity and whether it carries a border. See Colour for the whole rule.
text has no surface, so elevation is ignored.
color
The surface is white, so color reaches the border only. That is why the example below is outline: on a solid Box, which has no border, color makes no visible difference.
size
On a Box, size sets neither a height nor a type scale but the size of the sheet: its radius and its padding. A Box is as tall as what it holds, and its children bring their own typography.
elevation
padded and render
padded={false} is for full-bleed content: an image, a table, a list that draws its own rows. render renders the Box as an element other than a <div>.