Card
A box that groups related things: a header with its title, the content, and a footer. Its edge is a 1px ring with two soft shadows, never a border.
<Card> <CardHeader> <CardTitle>Signing key</CardTitle> <CardDescription>The key that signs act-as tokens.</CardDescription> <CardAction> <Button>Rotate</Button> </CardAction> </CardHeader> <CardContent padding="md">Rotating it signs every new token with the new key. Tokens already issued stay valid until they expire.</CardContent> <CardFooter> <CardDescription>Last rotated 12 days ago</CardDescription> </CardFooter></Card>Installation
import {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
CardToolbar,
} from "@/components/ui/card";Screens import it from this file. It passes the design system's Card through unchanged (ds/components/card.tsx).
Anatomy
- 1 · Card. The box: its fill, a 12px radius, and its edge and shadows. It has no padding of its own.
- 2 · Title. 13px medium. It can carry an icon, a count, badges and a switch.
- 3 · Description. 13px, in the secondary text color, under the title.
- 4 · Action. The header's right side: small controls.
- 5 · Content. Whatever the card holds. No padding unless asked.
- 6 · Footer. Text on its left, controls on its right, under a line.
A header
A title, or a title over a description. The header draws a line under itself whenever something follows it. With a title alone it is 52px tall. With a title and one line of description it is 64px. The title sits 4px into the padding above it, and the description 4px into the padding below it.
<Card> <CardHeader> <CardTitle>Recent calls</CardTitle> </CardHeader> <CardContent padding="md">The latest calls this agent made.</CardContent></Card><Card> <CardHeader> <CardTitle>Recent calls</CardTitle> <CardDescription>The latest calls this agent made.</CardDescription> </CardHeader> <CardContent padding="md">Select a row to open the audit event.</CardContent></Card>An action in the header
CardAction is the header's right side: one control, or several in a row. Beside a title alone it is centered on the title. Beside a title and a description it sits at the top, so a long description grows below it.
<Card> <CardHeader> <CardTitle>API keys</CardTitle> <CardAction> <Button iconStart={Plus}> New key </Button> </CardAction> </CardHeader> <CardContent padding="md">No key has been used yet.</CardContent></Card><Card> <CardHeader> <CardTitle>API keys</CardTitle> <CardDescription>A key signs an agent in. Create one for each agent, and revoke it when the agent is retired.</CardDescription> <CardAction> <Button iconStart={Plus}> New key </Button> </CardAction> </CardHeader> <CardContent padding="md">No key has been used yet.</CardContent></Card>Controls are 28px at most
A header, a footer and a toolbar hold small controls. A Button, a segmented control, an Input or a Select asked for at medium is drawn small there. This button asks for medium, 32px, and is drawn at 28px.
<Card> <CardHeader> <CardTitle>API keys</CardTitle> <CardAction> <Button size="md"> New key </Button> </CardAction> </CardHeader> <CardContent padding="md">No key has been used yet.</CardContent></Card>What a title carries
icon sits before the title, a step quieter than it. count says how many things the card holds, in a gray badge right after the title. When the title names the things, the badge is the number alone (“By model”, 6). When it does not, the badge adds the word (“3 agents”). badges takes a status or a tag after that. switch puts a switch before the title. The title is the switch's label, and the description lines up under the title.
<Card> <CardHeader> <CardTitle icon={Robot} count={6}> By model </CardTitle> </CardHeader></Card><Card> <CardHeader> <CardTitle count={["3 agents", "2 identities"]}>Consumers</CardTitle> </CardHeader></Card><Card> <CardHeader> <CardTitle badges={<Badge color="info">Preview</Badge>}>Triggers</CardTitle> </CardHeader></Card><Card> <CardHeader> <CardTitle switch={{ defaultChecked: true }}>Manual runs</CardTitle> <CardDescription>Let a person start a run by hand.</CardDescription> </CardHeader></Card>Clickable title
href makes the title a link to the card's fuller page. Point the card: the title turns secondary and the small chevron shows after it. Point the title: both turn full again. link is the app's router link. On a card that is itself the link (a tile), chevron draws the same chevron with no link of its own, so the card stays one tab stop.
<Card> <CardHeader> <CardTitle icon={History} href="/audit/events" link={ScopedLink}> Activity </CardTitle> </CardHeader></Card><Card> <CardHeader> <CardTitle href="/integrations" link={ScopedLink} badges={<IconTooltip tooltip="…" label="About Integration health" />}> Integration health </CardTitle> </CardHeader></Card>Padding
The card has no padding of its own. The header, the toolbar, the content and the footer each have a padding, the same on all four sides. The header, the toolbar and the footer take md, the card inset, 16px. The content takes none, so rows and tables pad themselves and run edge to edge. Content that pads itself asks for md. The rows here are drawn by hand to show the padding. On a screen a row is a Field with row, or a Table, and pads itself.
<Card> <CardHeader> <CardTitle>Notes</CardTitle> </CardHeader> <CardContent padding="md">Text that the content pads: the inset on all four sides.</CardContent></Card><Card> <CardHeader> <CardTitle>Rows</CardTitle> </CardHeader> <CardContent> <div className="px-card-inset py-card-inset-text">A row that pads itself</div> <div className="border-t border-border px-card-inset py-card-inset-text">Its rule runs edge to edge</div> </CardContent></Card>A toolbar
CardToolbar is a row of controls over the content: a search, filters, an action. It is a header without a title: the inset on all four sides, a line under it, small controls.
<Card> <CardContent> <CardToolbar> <Input className="max-w-xs" iconStart={MagnifyingGlass} placeholder="Search agents" aria-label="Search agents" /> </CardToolbar> <div className="px-card-inset py-card-inset-text">billing-assistant</div> <div className="border-t border-border px-card-inset py-card-inset-text">support-triage</div> </CardContent></Card>A footer
The header's two sides again: CardDescription is its text, on the left, and CardAction its controls, on the right. Either can be left out. The footer draws a line over itself whenever something precedes it.
<Card> <CardHeader> <CardTitle>Signing key</CardTitle> </CardHeader> <CardContent padding="md">Rotate the key that signs act-as tokens.</CardContent> <CardFooter> <CardDescription icon={Key}>Last rotated 12 days ago</CardDescription> <CardAction> <Button>Cancel</Button> <Button>Rotate</Button> </CardAction> </CardFooter></Card>Content that scrolls
scroll lets the content scroll. Give it a maximum height with a class, such as max-h-28. The header and the footer stay in place.
<Card> <CardHeader> <CardTitle>Agents</CardTitle> </CardHeader> <CardContent scroll className="max-h-28"> <div className="px-card-inset py-card-inset-text">billing-assistant</div> <div className="border-t border-border px-card-inset py-card-inset-text">support-triage</div> <div className="border-t border-border px-card-inset py-card-inset-text">release-notes-writer</div> <div className="border-t border-border px-card-inset py-card-inset-text">invoice-reader</div> <div className="border-t border-border px-card-inset py-card-inset-text">lead-scorer</div> </CardContent></Card>Outline
variant="outline" is the card's shape with no fill: its 1px edge alone, with the page showing through. It is a quiet container, the box an empty state stands in. In dark its edge is the secondary neutral border.
<Card variant="outline"> <CardContent padding="md">A quiet container. The page shows through.</CardContent></Card>Tones
tone="destructive" is the danger zone: a muted red edge, a faint red header with a red line under it, and a red title and icon. The description stays gray. tone="warning" gives the card a pale amber fill, and its title, description and icon the same amber. No screen uses the warning tone today. In light its text measures 1.8:1 on its fill.
<Card tone="destructive"> <CardHeader> <CardTitle>Delete workspace</CardTitle> <CardDescription>This removes the workspace and everything in it.</CardDescription> <CardAction> <Button color="error" emphasis="low">Delete</Button> </CardAction> </CardHeader></Card><Card tone="warning"> <CardHeader> <CardTitle>This gateway has not synced for 2 hours</CardTitle> </CardHeader></Card>A card that is one target
clickable makes the whole card one thing to click. Under the pointer its fill gets fainter and its edge turns blue. render makes the card a button or a link. Anything inside the card can change on that same hover: give it a class that starts with group-hover/clickable:. Here the arrow gets darker. Every card, clickable or not, is also a group/card, so its content can answer the card's hover with group-hover/card:.
<Card clickable render={<a href="#clickable" />}> <CardHeader> <CardTitle>Connect a model</CardTitle> <CardDescription>Route your agents' calls through a provider you choose.</CardDescription> <CardAction> <ArrowRight className="size-3.5 text-neutral-fg-muted group-hover/clickable:text-neutral-fg" /> </CardAction> </CardHeader></Card>In the dashboard
Where the dashboard draws it today.
The dashboard's own Card
components/ui/card.tsx passes this Card through unchanged. 127 files under app/ and components/ draw a card, 123 of them through this path.
components/ui/card.tsx
A list
The Table draws its rows on a Card, with its search and filters in a CardToolbar and its pager in a CardFooter.
ds/components/table/data-table.tsx
The danger zone
A destructive card around a screen's risky actions: deleting a workspace, an agent or a tool connection, suspending an agent, disabling a gateway. Eight files draw one.
app/(authenticated)/[kind]/[scopeId]/settings/danger-zone/page.tsx
A page with nothing yet
The outline card around an empty state. It fills the height left on the page.
components/shared/empty-state.tsx (EmptyStateCard)
A choice
A clickable card as one radio choice among several. It has no render: the radio around it takes the keyboard. It is the only clickable card in the dashboard.
components/ui/radio-group.tsx
Accessibility
A card is a <div> with no role, and its title is a <div> too, not a heading: a screen reader reads the title, but its list of headings skips it.
A clickable card with render is the button or the link it is given, so the keyboard reaches it. The Card adds no focus ring of its own: a focused clickable card looks the same as one at rest. A clickable card with no render stays a <div> with no role: the keyboard does not reach it, and a screen reader is not told it can be pressed.
A title with href is one link, its words its name; the chevron is hidden from a screen reader. The link takes the keyboard's focus with a visible ring and shows its chevron then; the card around it is not a second tab stop.
A title's switch is named by the title. The title is not a label you can press: a click on it does not flip the switch. Content that scrolls is a tab stop when it holds more than fits, so the keyboard can scroll it.
What a screen reader says for a card was not tested.
API Reference
Card
Besides these, the props of a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "default" | The white card, or its shape with no fill and its 1px edge alone. |
tone | "destructive" | "warning" | — | The danger zone, or an amber fill with amber text. |
clickable | boolean | false | The whole card is one target, with a hover on its fill and its edge. |
render | ReactElement | function | — | The element the card is, in place of a <div>: a button or a link for a clickable card. |
The parts
Each part is a <div> and takes a div's props, besides what is listed.
| Part | What it is | Its own props |
|---|---|---|
CardHeader | The title, a description under it, and an action at the right. A line under it when something follows. | padding, md by default. |
CardTitle | The card's name. | icon, count, badges, switch, href, link, chevron. |
CardDescription | The line under the title. In a footer, its text on the left. | icon, at 14px before the text. |
CardAction | The right side of a header or a footer: one control or several. | None. |
CardToolbar | A row of controls over the content. A line under it when something follows. | padding, md by default. |
CardContent | Whatever the card holds. | padding, none by default; scroll, off by default. |
CardFooter | Text on the left, controls on the right. A line over it when something precedes. | padding, md by default. |
CardTitle
| Prop | Type | Default | Description |
|---|---|---|---|
icon | ComponentType<{ className?: string }> | — | An icon before the title, at 14px, a step quieter than the title. |
count | CardCount | CardCount[] | — | How many things the card holds: a number (written with thousands separators), a text ("5 events"), or an object with a value, a color, an emphasis, a hover title and a test id. Several counts are a list. |
badges | ReactNode | — | A status or a tag, after the title and its count. |
switch | Omit<SwitchProps, "aria-label" | "aria-labelledby"> | — | A switch before the title. It takes the Switch's props. The title is its label, so it takes no label of its own. |
href | string | — | Where the title leads. Its words become the link. While the card is pointed they turn secondary and the small chevron shows 6px after them, in their color; pointed or focused themselves, both are full again. Its count and badges go to the header's right end. |
link | ElementType | "a" | The element that navigates to href: the app's router link. |
chevron | boolean | false | For a card that is itself the link: the small chevron after the title while the card is pointed or its link focused, and no link in the title. |
padding
The same on all four sides of the part. md is the card inset, 16px. The other values are for a box that should not use the card inset. Nothing written says which boxes those are.
| Value | Padding |
|---|---|
none | 0 |
xs | 8px |
sm | 12px |
md | 16px, the card inset (--card-inset) |
lg | 20px |
xl | 24px |
Tokens
In ds/tokens/card.css.
| Token | Value | What it sets |
|---|---|---|
--card-background | The card color | The card's fill. |
--card-shadow | Stacking level 2 | The card's edge and shadows: a 1px ring over two soft drops. |
--card-inset | 16px | How far everything in a card sits from its edge. In a class: p-card-inset, px-card-inset, mx-card-inset. |
--card-inset-leading | 4px | What a row of text alone gives up above and below. |
--card-inset-text | 12px | Above and below a row of text alone: the inset minus the leading. In a class: py-card-inset-text. |
--card-icon | The secondary text color | The color of the title's icon. |
--card-outline-background | None | The outline card's fill. |
--card-outline-shadow | A 1px ring | The outline card's edge. In dark, the secondary neutral border. |
--card-clickable-hover-background | A faint wash | A clickable card's fill under the pointer. |
--card-clickable-hover-shadow | A blue 1px ring over the two drops | A clickable card's edge and shadows under the pointer. |
--card-destructive-* | Six tokens | The danger card's edge and shadows, its header's fill and line, and the colors of its title, description and icon. |
--card-warning-* | Two tokens | The warning card's fill, and the color of its text. |
Rules
Written down
One inset, 16px, on all four sides
Every box in a card pads the card inset on all four sides: the header, content that pads itself, the footer, a nested box. It is one token, --card-inset, so one value moves them all.
From .claude/rules/dashboard-ui.md (rule 8) and ds/tokens/card.css.
A row pads the same above and below
12px around text alone, 16px around a control. A badge, a switch, a checkbox and a radio count as controls.
From .claude/rules/dashboard-ui.md (rule 8).
Header, footer and toolbar controls are 28px at most
The card draws a control asked for at medium as small. Medium is for the page header.
From .claude/rules/dashboard-ui.md (rule 8) and ds/components/card.tsx.
The edge is a shadow, never a border
The designer builds cards from shadows only. The 1px edge is a ring painted just outside the box, so the box keeps its size and its content never shifts.
From ds/tokens/card.css.
A control at a box's edge has equal space around it
A control at a card's edge or corner has the same space above it, beside it and below it.
From .claude/rules/dashboard-ui.md (rule 9).
A count goes after the title
How many things a card holds is a badge right after its title. It is never at the header's right: that side is for actions and controls. The badge is gray unless the count is itself a warning, such as a count of denies.
From ds/components/card.tsx and ds/README.md (Card).
A search or a filter over the content is a CardToolbar
CardToolbar is the row of controls over the content: a header without a title. A screen does not make that row by hand.
From ds/components/card.tsx, ds/README.md (Card) and .claude/rules/dashboard-ui.md (rule 1).
Screens use the Card, they do not draw one
A screen never styles a div into a card, and never restyles a Card with classes.
From .claude/rules/dashboard-ui.md (rule 1).
The keyboard reaches a clickable card
Every action the mouse reaches, the keyboard reaches too. render is how a clickable card becomes a button or a link.
From design/principles.md (Accessibility, Keyboard parity).
Open questions
Does a paragraph of text in a card pad 16px or 12px above and below?
OpenContent that pads itself takes the inset, 16px. A row of text alone pads 12px (rule 8). Nothing written says which one a paragraph is.
Not looked up.
Should a card's title be a heading?
OpenToday it is a <div>, so a screen reader's list of headings skips it. The design principles rank the section heading one rung above the card title, but nothing written says which tag a card title is.
Not looked up.
Should a card refuse clickable without render?
OpenToday it allows it. The radio choice relies on this: the radio around the card takes the keyboard.
Not looked up.