Card
A compound layout component for displaying grouped content. Built with plain HTML elements (no Base UI dependency). Follows the compound pattern: Card.Root, Card.Header, Card.Title, Card.Description, Card.Content, Card.Footer.
Import
import { Card } from "chunks-ui";Basic Usage
<Card.Root>
<Card.Header>
<Card.Title>Project Alpha</Card.Title>
<Card.Description>A brief description of the project.</Card.Description>
</Card.Header>
<Card.Content>
<p>Main content goes here.</p>
</Card.Content>
<Card.Footer>
<Button variant="outlined" color="secondary">Cancel</Button>
<Button>Save</Button>
</Card.Footer>
</Card.Root>Project Alpha
A brief description of the project.
Main content goes here.
Minimal Card
You can use any subset of compound parts. Each one gets the same padding from the edges of the card:
<Card.Root>
<Card.Content>
<p>Simple card with content only.</p>
</Card.Content>
</Card.Root>Simple card with content only.
With Custom Content
<Card.Root className="max-w-sm">
<Card.Header>
<Card.Title>Team Members</Card.Title>
<Card.Description>Manage your team members and roles.</Card.Description>
</Card.Header>
<Card.Content>
<div className="flex flex-col gap-3">
<div className="flex items-center gap-3">
<Avatar fallback="AJ" size={32} />
<div>
<p className="text-sm font-medium">Alice Johnson</p>
<p className="text-xs text-muted-foreground">Admin</p>
</div>
</div>
<div className="flex items-center gap-3">
<Avatar fallback="BS" size={32} />
<div>
<p className="text-sm font-medium">Bob Smith</p>
<p className="text-xs text-muted-foreground">Member</p>
</div>
</div>
</div>
</Card.Content>
<Card.Footer>
<Button>Invite Member</Button>
</Card.Footer>
</Card.Root>Team Members
Manage your team members and roles.
Alice Johnson
Admin
Bob Smith
Member
Styling
- No shadow.
Card.Roothas a border and a background, and no shadow. To add one, pass a class:<Card.Root className="shadow-md">. - Spacing comes from the root.
Card.Rootis a flex column withpy-6andgap-6.Card.Header,Card.ContentandCard.Footerhave onlypx-6. So the content of any subset of parts is 24px from every edge, with 24px between parts (6 spacing units at the default--spacing). - Dividers. A
Card.Headerwithborder-bgetspb-6, and aCard.Footerwithborder-tgetspt-6, so the border sits 24px from the text. To change that padding, use the same variant, for example[.border-b]:pb-4. A plainpb-4loses to it. Only the exactborder-bandborder-tclasses trigger this; withborder-b-2,border-yorborder, add the padding yourself. - Upgrading. A card that starts with
Card.Headerlooks the same as before. Every child of the root is now a flex item, and padding on the parts orspace-y-*on the root adds to the root’spy-6andgap-6. The changelog lists each case.
To change the spacing, set the vertical padding and the gap on the root, and the horizontal padding on the parts:
<Card.Root className="gap-4 py-4">
<Card.Content className="px-4">
<p>Tighter card.</p>
</Card.Content>
</Card.Root>Compound Parts
| Part | Description |
|---|---|
Card.Root | Outer container. Rounded border and background, no shadow. Vertical flex with gap-6 py-6. |
Card.Header | Top section. Vertical flex with gap-1.5 px-6, and pb-6 when it has border-b. |
Card.Title | Heading rendered as <h3>. Semibold, tight tracking. |
Card.Description | Subtext below the title. text-muted-foreground. |
Card.Content | Main body area. Padding px-6. |
Card.Footer | Bottom section. Horizontal flex with gap-2 px-6, and pt-6 when it has border-t. |
Props
All compound parts accept standard HTML div props (or h3/p for Title/Description) plus className for additional styling. There are no component-specific variant props.