Card
A Box with the parts a card is made of laid out on it: a title, a subtitle, a body and a footer. Every Box prop passes straight through, so a card is styled on exactly the same axes as the box it is.
import { Card } from 'neba';
<Card title="Starter" subtitle="One project" footer={<Button>Choose</Button>}>
Body
</Card>;Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variantshared | 'solid' | 'outline' | 'text' | 'outline' | Weight of the surface: filled, hairline, or none |
| sizeshared | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Corner radius, padding, and the type scale of the header and body |
| colorshared | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | Semantic colour role. The surface is white, so it reaches the hairline and the dividers only |
| 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 |
| title | ReactNode | — | The heading. Pass a real heading element when it belongs in the document outline |
| subtitle | ReactNode | — | A second line under the title, one step down the type scale and muted |
| headerAction | ReactNode | — | Content pinned to the end of the header row — a menu button, a status chip |
| footer | ReactNode | — | The bottom area, laid out as a wrapping row |
| dividers | boolean | false | Separates the sections with a hairline instead of space, edge to edge |
| children | ReactNode | — | The card's body |
Takes every Box prop. The one exception is padded, which is omitted because a card redistributes that padding section by section.
Examples
Sections
The sections are props rather than compound sub-components. The arrangement is fixed, and what a caller wants to decide is what goes in each slot, not what order the slots come in. A slot you do not pass is not rendered.
Dividers
Turn dividers on and the sections are separated by a hairline instead of by space. The lines have to reach both edges, so the padding moves from the sheet onto each section.
Sizes
size sets the sheet's radius and padding together with the type scale of the header and the body. The title sits one step above the body, the subtitle one step below it.
Holding controls
A card is a box, so the controls inside it sit on glass. When the title belongs in the document outline, pass a real heading — title={<h2>…</h2>}. It inherits the card's type scale rather than the browser's.