UI.MD

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, CardHeader, CardTitle, CardDescription, CardAction,
  CardContent, CardFooter, CardRows, CardRow, CardTableHeader,
  CardTableBody, DashboardCardHeader, MetricCardValue,
} from "@/components/ui/card"

Examples

Default

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.

With Footer Border

Add border-t and pt-4 to CardFooter to close the card off with a divider. The line sits 20px below the content (CardContent's pb-5) and 16px above the actions, which keep the footer's default 20px to the bottom edge - the exact inverse of the header divider's rhythm.

Notifications

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

With Form

Card wrapping form inputs: shows Card, Input, and Button working together.

Create project
Deploy your new project in one click.

With Action

CardAction places a control in the top-right of the header.

Team Members
Manage your team and permissions.
JD

Jane Doe

jane@example.com

Admin
AS

Alex Smith

alex@example.com

Member

With Rows

CardRow creates a bordered list layout for settings or navigation.

Settings
Manage your account preferences.

Notifications

Push and email alerts

Security

Password and 2FA

Language

English (US)

Compact Header

DashboardCardHeader + MetricCardValue for data display cards.

Weekly Steps
47,291
Goal: 50,000 steps2709 to go

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-3 days
Subtotal$48.00

Tabbed Filter

The canonical pattern for a card with tabbed navigation. Tab (or segmented) navigation never goes inside DashboardCardHeader - its h-12 band is sized for a single 32px icon action, so a control cluster crammed in there sits cramped and off-center. Instead the header carries the title + one action, the tabs get their own region below it (the default py-5 gives 20px above and below the pill), and a border-t closes the filter off from the list it filters.

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

API Reference

PropTypeDefaultDescription
variantCard"default" | "dotgrid""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.
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*DashboardCardHeaderstring-Header label, truncated when it overflows.
actionDashboardCardHeaderReact.ReactNode-Optional control rendered on the right side of the header.
linkDashboardCardHeader{ label: string; onClick: () => void }-Subtle text-button link on the right of the header; ignored when action is set.
value*MetricCardValueReact.ReactNode-The large metric value.
goal*MetricCardValueReact.ReactNode-Goal line rendered under the value.
unitMetricCardValuestring-Unit 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.ReactNode-Optional inline controls rendered beside the value (e.g. +/- buttons).
columns*CardTableHeaderstring[]-Column labels for the header row.
gridClassName*CardTableHeaderstring-Grid classes matching the body rows, e.g. grid-cols-[10rem_1fr_5rem].