Skip to content

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.

tsx
import { Card } from 'neba';

<Card title="Starter" subtitle="One project" footer={<Button>Choose</Button>}>
  Body
</Card>;

Props

PropTypeDefaultDescription
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
elevationshared0 | 1 | 2 | 30Drop shadow depth. Ignored when variant is text
titleReactNodeThe heading. Pass a real heading element when it belongs in the document outline
subtitleReactNodeA second line under the title, one step down the type scale and muted
headerActionReactNodeContent pinned to the end of the header row — a menu button, a status chip
footerReactNodeThe bottom area, laid out as a wrapping row
dividersbooleanfalseSeparates the sections with a hairline instead of space, edge to edge
childrenReactNodeThe 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.

Released under the MIT License