Card

A container with header, content, and footer sections. Includes dashboard and metric card variants.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/card.json

Usage

import {
  Card, CardMedia, CardHeader, CardTitle, CardDescription, CardAction,
  CardContent, CardFooter, CardRows, CardRow, CardTableHeader,
  CardTableBody, DashboardCardHeader, MetricCardValue,
} from "@/components/ui/card"

Examples

Default

Header, content, and footer are each optional. This one skips CardContent and lets the description carry the body, which is the shape a short confirmation card wants.

Notifications
Choose which notifications you’d like to receive and how they’re delivered.

With Header Border

Add border-b to CardHeader to separate the header from content.

Notifications

Choose which notifications you’d like to receive and how they’re delivered.

Add border-t to CardFooter to close the card off with a divider. It supplies its own 20px above the actions as soon as it is bordered, matching the 20px already below them, so there is no pt-* to remember.

Notifications
Choose which notifications you’d like to receive and how they’re delivered.

With Form

A form inside a card: field between the fields, and Field owns the label-to-control gap. No top-gap override: CardContent sees the fields and opens to 16px under a borderless header, where prose hugs it at 8px.

Create project
Deploy your new project in one click.

With Action

CardAction places a control in the top-right of the header. The body is CardRows + CardRow rather than a hand-rolled stack: a member list is a row list, so each row owns its padding and hairline and there is no inter-row gap to guess.

Team members
Manage your team and permissions.
JD

Jane Doe

jane@example.com

Admin
AS

Alex Smith

alex@example.com

Member

With Rows

CardLinkRow is a row in a card that links somewhere: a label, an optional icon and line under it, and a chevron. Use CardRow for rows that only display.

CardFooter tone="muted" is the same rule-and-fill band TableFooter ships, for a buy row or totals row that should pair with a table beside it. CardDescription size="lg" steps the description to 16px where it carries the card's message.

Complete the set
Add the matching mug and the print ships in the same box.
$18.00

Clickable Rows

Pass render to CardRow and the whole row becomes that element, with a hover fill and a focus ring. layout="block" stacks text in a column. Use CardLinkRow instead when a row wants a chevron or a count.

Version history

Flush Rows

inset="flush" drops the side padding for a row list inside CardContent, which already pads. The first row loses its top padding and the last its bottom, so the list ends on the card's own padding. Leave it off for rows that sit directly in the card.

Matches found
Two posts look like this one.
Shipping a design systemPublished in March
Tokens before componentsPublished in June

Compact Header

DashboardCardHeader + MetricCardValue for data display cards.

Weekly steps
47,291
Goal: 50,000 steps2,709 to go

Header Action Alignment

Action seating, default flush. A Badge, count, or caption puts its own edge on the 16px inset, level with the title. An icon Button or Kebab carries ~6px of hit-area chrome past its glyph, so it needs actionInset="icon" to seat the glyph there; using it on a bare Badge pulls the count 6px too tight.

Captures15
NewestToday
Oldest5d ago
Weekly steps
Today8,120
Goal10,000

Table Header

CardTableHeader adds column labels that align with grid rows below.

api-serverHealthy99.9%
web-appHealthy99.7%
workerDegraded97.2%

Expandable

Reveal detail rows with a smooth disclosure. The summary stays put and the toggle lives in the header (neither moves), while the rows expand via Collapsible - a measured height animation that eases open and closed. The card's height just follows the Collapsible, so there's no snap or layout shift.

Order summary
1 item · ships in 2 to 3 days
Subtotal$48.00

Tabbed Filter

A card whose list is filtered by tabs. Pill tabs stay out of DashboardCardHeader: the framed track fills its 48px band. Give them their own region below, closed off from the list by a border-t. For tabs in the header itself, use Tabs variant="line".

Activity
Deploy to production succeededDeploy · 1h ago
Julik requested changes on #128Review · 3h ago
Andrew commented on RegistryComment · 2m ago

Dotgrid

Set variant="dotgrid" to fill the card with a faint dot-grid canvas. The dots paint behind the content, so children sit on top of the staging surface. Used for positioning and placement demos.

Canvas
A dot-grid staging surface for positioning and placement demos.

Content sits on the canvas

featured rings the card in the accent colour, to mark the recommended plan in a row of them. It composes with variant, so it is a boolean, not a variant value.

Pro
For teams that ship every week.

Unlimited projects and priority support.

Muted

variant="muted" swaps the ring for a quiet muted fill: no edge, no shadow, same radius, padding and parts. For a grid that groups content without raising it. Keep it to plain content, since a muted band inside it does not show.

Weekly digest
Every Monday, the week’s changes in one email.

Sent to 1,240 people last week.

With Media

CardMedia puts an image flush at the top, clipped to the card's corners, with the copy below. For a card that leads with a picture but keeps its edge.

Spring collection
Twelve pieces in linen and washed cotton.

API Reference

PropTypeDefaultDescription
variantCard"default" | "dotgrid" | "muted""default"Visual treatment. dotgrid fills the card with a faint dot-grid canvas that paints behind the content, a staging surface for positioning and placement demos. muted is a quiet bg-muted fill with no ring or shadow, for a grid that groups content without raising it; it needs no perimeter room.
featuredCardbooleanfalseRings the card in the accent colour to mark the recommended one in a set, such as the plan to pick. Independent of variant.
sizeCardDescription"default" | "lg""default"default is 14px, a supporting line. lg is 16px, for a card whose description is its message and should read at the page description's size rather than as fine print.
toneCardFooter"default" | "muted""default"muted paints the footer as a band: a rule above and the muted fill, the same band TableFooter ships. Works on a card in both modes, since the muted fill sits one step off the card colour in light and dark.
layoutCardRow"row" | "stack""row"row lays the children on one line, vertically centred. block stacks them in a column that fills the width, for a row of text and controls.
insetCardRow"default" | "flush""default"default pads 16px each side, for rows sitting directly in the card. flush drops the side padding for a list inside CardContent; the first row also loses its top padding and the last its bottom.
renderCardRowReact.ReactElementNoneMakes the whole row one link or button: pass the element (<a href />, <Link href />, <button type="button" />) and the row's children go inside it. Adds a hover fill, a focus ring and a pointer cursor, and hides the rules around the hovered row. For a chevron, a count and a description line use CardLinkRow.
renderCardLinkReact.ReactElementNonePut CardLink in CardTitle to make the whole card one link: it covers the card, draws the focus ring inside the corners, and adds no hover fill. Pass render={<Link href="..." />} for a router link, or href for a plain <a>. A CardAction in the same card stays clickable above the link, and CardMedia lets clicks through, with no extra classes.
aspectCardMedia"landscape" | "wide" | "square""landscape"The image's shape: 3:2, 16:9 or 1:1. Reserved before the image loads. A plain <img> is stretched to cover.
animateHeightCardbooleanfalseSmoothly animates the card's own height when its content size changes. Opt-in; leave off when a child already animates its own height (e.g. an inner Collapsible).
title*DashboardCardHeaderstringNoneHeader label, truncated when it overflows.
actionDashboardCardHeaderReact.ReactNodeNoneOptional control rendered on the right side of the header.
actionInsetDashboardCardHeader"icon" | "flush""flush"How the action seats against the right edge. flush (default) puts the action's own box edge on the content inset, so a Badge, count, or caption aligns with the title. icon outdents 6px for an action whose box extends past what you see (an icon Button or Kebab's transparent hit area, a ghost text button's padding), seating the glyph on the inset instead. The default is flush because a badge dropped in unadorned must look right with no flag; the button case declares its own chrome compensation.
linkDashboardCardHeader{ label: string; onClick: () => void }NoneSubtle text-button link on the right of the header; ignored when action is set.
insetDashboardCardHeader"default" | "loose""default"Side padding, which must match the body's below it. default (16px) is the row tier and fits most cards. loose (24px) is the prose tier, for a card whose body is paragraphs rather than rows, where 16px reads thin once the card is wide. Set the body to match in the same edit: the header and the content share one left edge, so moving either alone puts the title 8px inboard of every line beneath it.
value*MetricCardValueReact.ReactNodeNoneThe large metric value.
goal*MetricCardValueReact.ReactNodeNoneGoal line rendered under the value.
unitMetricCardValuestringNoneUnit suffix appended to the goal line.
deltaMetricCardValue{ value: number; label?: string }NoneProgress remainder line: positive values render label (default {value} to go), zero or below renders Goal reached!.
childrenMetricCardValueReact.ReactNodeNoneOptional inline controls rendered beside the value (e.g. +/- buttons).
columns*CardTableHeaderstring[]NoneColumn labels for the header row.
gridClassName*CardTableHeaderstringNoneGrid classes matching the body rows, e.g. grid-cols-[10rem_1fr_5rem].
variantCard"default" | "dotgrid" | "muted" = "default"Visual treatment. dotgrid fills the card with a faint dot-grid canvas that paints behind the content, a staging surface for positioning and placement demos. muted is a quiet bg-muted fill with no ring or shadow, for a grid that groups content without raising it; it needs no perimeter room.
featuredCardboolean = falseRings the card in the accent colour to mark the recommended one in a set, such as the plan to pick. Independent of variant.
sizeCardDescription"default" | "lg" = "default"default is 14px, a supporting line. lg is 16px, for a card whose description is its message and should read at the page description's size rather than as fine print.
toneCardFooter"default" | "muted" = "default"muted paints the footer as a band: a rule above and the muted fill, the same band TableFooter ships. Works on a card in both modes, since the muted fill sits one step off the card colour in light and dark.
layoutCardRow"row" | "stack" = "row"row lays the children on one line, vertically centred. block stacks them in a column that fills the width, for a row of text and controls.
insetCardRow"default" | "flush" = "default"default pads 16px each side, for rows sitting directly in the card. flush drops the side padding for a list inside CardContent; the first row also loses its top padding and the last its bottom.
renderCardRowReact.ReactElementMakes the whole row one link or button: pass the element (<a href />, <Link href />, <button type="button" />) and the row's children go inside it. Adds a hover fill, a focus ring and a pointer cursor, and hides the rules around the hovered row. For a chevron, a count and a description line use CardLinkRow.
renderCardLinkReact.ReactElementPut CardLink in CardTitle to make the whole card one link: it covers the card, draws the focus ring inside the corners, and adds no hover fill. Pass render={<Link href="..." />} for a router link, or href for a plain <a>. A CardAction in the same card stays clickable above the link, and CardMedia lets clicks through, with no extra classes.
aspectCardMedia"landscape" | "wide" | "square" = "landscape"The image's shape: 3:2, 16:9 or 1:1. Reserved before the image loads. A plain <img> is stretched to cover.
animateHeightCardboolean = falseSmoothly animates the card's own height when its content size changes. Opt-in; leave off when a child already animates its own height (e.g. an inner Collapsible).
title*DashboardCardHeaderstringHeader label, truncated when it overflows.
actionDashboardCardHeaderReact.ReactNodeOptional control rendered on the right side of the header.
actionInsetDashboardCardHeader"icon" | "flush" = "flush"How the action seats against the right edge. flush (default) puts the action's own box edge on the content inset, so a Badge, count, or caption aligns with the title. icon outdents 6px for an action whose box extends past what you see (an icon Button or Kebab's transparent hit area, a ghost text button's padding), seating the glyph on the inset instead. The default is flush because a badge dropped in unadorned must look right with no flag; the button case declares its own chrome compensation.
linkDashboardCardHeader{ label: string; onClick: () => void }Subtle text-button link on the right of the header; ignored when action is set.
insetDashboardCardHeader"default" | "loose" = "default"Side padding, which must match the body's below it. default (16px) is the row tier and fits most cards. loose (24px) is the prose tier, for a card whose body is paragraphs rather than rows, where 16px reads thin once the card is wide. Set the body to match in the same edit: the header and the content share one left edge, so moving either alone puts the title 8px inboard of every line beneath it.
value*MetricCardValueReact.ReactNodeThe large metric value.
goal*MetricCardValueReact.ReactNodeGoal line rendered under the value.
unitMetricCardValuestringUnit suffix appended to the goal line.
deltaMetricCardValue{ value: number; label?: string }Progress remainder line: positive values render label (default {value} to go), zero or below renders Goal reached!.
childrenMetricCardValueReact.ReactNodeOptional inline controls rendered beside the value (e.g. +/- buttons).
columns*CardTableHeaderstring[]Column labels for the header row.
gridClassName*CardTableHeaderstringGrid classes matching the body rows, e.g. grid-cols-[10rem_1fr_5rem].