Card
A layered surface with header, content, and footer — semantic by default, clickable via asChild, with spotlight glow, status edges, KPI metrics, and CLS-safe media.
Installation#
pnpm dlx shadcn@latest add @davinciui/cardUsage#
Composition: Card → CardHeader (CardTitle + CardDescription + CardAction) + CardContent + CardFooter.
Spacing: Section gaps and insets follow the --card-spacing CSS variable — override per card with className="[--card-spacing:--spacing(6)]".
Clickable: never put onClick on a div — use interactive asChild with a real a, button, or Link child so keyboard, screen reader, and middle-click keep working.
Loading: match the layout with Skeleton lines inside CardContent and set aria-busy="true" — never a spinner for content loading.
Edge to edge: Bleed content with -mx-(--card-spacing) and drop the section gap above a footer with -mb-(--card-spacing) on CardContent.
Interactive#
Status#
Metric#
Media#
Elevated#
Spotlight#
Glass#
Outline#
Size#
Spacing#
Edge to Edge#
Image#
RTL#
Composition#
Use the following composition to build a Card:
Card
├── CardHeader
│ ├── CardEyebrow
│ ├── CardTitle
│ ├── CardDescription
│ └── CardAction
├── CardMedia
├── CardContent
├── CardMetric
└── CardFooterAPI Reference#
| Prop | Type | Default |
|---|---|---|
CardRoot container for card content. | Component | — |
variantSurface treatment. Elevated lifts on hover; glass is frosted for overlays. | "default" | "elevated" | "outline" | "glass" | "default" |
sizeCard density via the shared --card-spacing variable (Card). | "sm" | "default" | "lg" | "default" |
asChildRender on a semantic child (<a>, <button>, <Link>). Required for clickable cards (Card, CardTitle). | boolean | false |
interactiveClickable affordance — hover lift, press compression, keyboard focus ring. Combine with asChild (Card). | boolean | false |
selectedSelected state for pickers and grids. Sets data-selected (Card). | boolean | false |
status2px gradient accent along the top edge. Sets data-status (Card). | "default" | "success" | "info" | "warning" | "destructive" | "default" |
spotlightCursor-tracked surface wash + border glow. Use on one featured card per view (Card). | boolean | false |
CardHeaderTitle, description, and optional action row. | Component | — |
CardEyebrowQuiet kicker above the title. Sentence case by default. | Component | — |
CardTitleCard title. Renders h3 by default; override the level with asChild. | Component | — |
CardDescriptionHelper text under the title. Renders a paragraph. | Component | — |
CardActionTop-right header slot, e.g. a button or badge. | Component | — |
CardMediaCLS-safe cover media with hover zoom. ratio: video | wide | square. | Component | — |
CardMetricKPI figure with tabular numerals that won't jitter on update. | Component | — |
CardContentMain card body. | Component | — |
CardFooterActions and secondary content at the bottom. | Component | — |
classNameAdditional CSS classes. | string | — |
Accessibility#
Cards are plain divs unless asChild renders a real link or button. Interactive mode adds a focus-visible ring and the base card shows a focus-within ring, while CardTitle defaults to h3.
Motion#
Elevated and interactive cards lift with 300ms cubic-bezier shadow transitions, the spotlight fades over 300ms, and CardMedia zooms images over 500ms. motion-reduce removes transitions, spotlight layers, lift and image zoom.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

