Card
Displays a card with header, content, and footer.
When to Use
Use Card when you need to:
- Group related content and actions into a single visual unit
- Display summary information like stats, profiles, or previews
- Create form containers with a clear header, body, and footer
- Build grid layouts of clickable content entries (dashboards, galleries)
- Present media content with associated metadata and actions
When Not to Use
- Simple text blocks without actions - use plain typography or a
div - Full-page layouts - use section elements or page-level containers
- Expandable/collapsible content - use Accordion or Collapsible
- Alert or status messages - use Alert for contextual feedback
Login Form
A card with a login form, including CardAction for the sign-up link.
Simple
Basic card with title, description, content, and footer.
This is the card content. You can put any content here.
With Image
Card with an image header using AspectRatio for consistent sizing.
Discover our collection of wholesome and delicious meal ideas.
With Action
Card with a header action button using CardAction, positioned top-right.
Push Notifications
Receive push notifications
Email Updates
Get weekly email updates
Card Grid
Multiple cards in a responsive grid layout for dashboards and navigation.
UX & Design Guidelines
Visual Hierarchy
Use CardTitle for the primary heading and CardDescription for supporting context. Place the most important action in CardFooter and use CardAction for secondary actions positioned in the header. Limit to one primary action per card.
Spacing & Layout
Cards use px-6 horizontal padding and py-6 vertical padding by default. When placing cards in grids, use gap-4 for standard spacing or gap-6 for more breathing room. Keep card content concise to maintain scanability.
Responsive Behavior
Use responsive grid columns like md:grid-cols-2 or md:grid-cols-3 for card grids. Cards should stack to a single column on mobile. Set max-w-sm on standalone cards to prevent them from stretching too wide on large screens.
Color & Contrast
Cards use bg-card with text-card-foreground for the container, ensuring proper contrast in both light and dark modes. Borders use the semantic border token. Use text-muted-foreground for secondary text like descriptions.
Accessibility
Keyboard Navigation
- Tab -- Move focus through interactive elements within the card
- Enter or Space -- Activate buttons and links inside the card
- For clickable cards, add Enter handler via
onKeyDownwithtabIndex={0}
Screen Reader Support
- Use
role="article"for standalone content cards to convey meaning - Associate the card with its title using
aria-labelledbypointing to theCardTitleid - Interactive cards that act as links should have
aria-labeldescribing the destination - Dynamic card content should use
aria-live="polite"to announce updates
Semantic Structure
CardTitle renders as a div by default. For proper document outline, ensure heading levels are consistent with the page hierarchy. CardDescription provides supporting text that screen readers announce alongside the title when using aria-describedby.
Focus Management
Cards are not focusable by default since they are containers, not interactive elements. When making a card clickable, add tabIndex={0} and a visible focus ring with focus-visible:ring-[3px]. Ensure that individual interactive elements within the card remain independently focusable.
ARIA Attributes
{/* Standalone content card with article role */}
<Card role="article" aria-labelledby="card-title-1">
<CardHeader>
<CardTitle id="card-title-1">Project Status</CardTitle>
<CardDescription>Current progress and milestones</CardDescription>
</CardHeader>
<CardContent>...</CardContent>
</Card>
{/* Interactive card as a link */}
<Card
role="link"
tabIndex={0}
aria-label="View analytics dashboard"
className="cursor-pointer"
onClick={handleNavigate}
onKeyDown={(e) => e.key === "Enter" && handleNavigate()}
>
<CardHeader>
<CardTitle>Analytics</CardTitle>
</CardHeader>
</Card>
{/* Card with live region for dynamic content */}
<Card>
<CardHeader>
<CardTitle>Notifications</CardTitle>
</CardHeader>
<CardContent aria-live="polite">
{notifications.map(n => <p key={n.id}>{n.text}</p>)}
</CardContent>
</Card>Related Components
Accordion
A vertically stacked set of interactive headings for expandable content.
Collapsible
An interactive component that expands and collapses a panel.
Separator
Visually or semantically separates content within or between cards.
Aspect Ratio
Displays content within a desired ratio, commonly used for card images.
API Reference
The Card component is composed of several sub-components. Each accepts standard HTML div attributes in addition to the props listed below.
Card
| Prop | Type | Default | Description |
|---|---|---|---|
| allowOverflow | boolean | false | Allow content to overflow the card boundaries (useful for dropdowns, menus, etc.). |
| className | string | — | Additional CSS classes to apply to the card container. |
| children | ReactNode | — | Card content, typically composed of CardHeader, CardContent, and CardFooter. |
CardHeader
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the header section. |
| children | ReactNode | — | Header content (CardTitle, CardDescription, CardAction). |
CardTitle
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the title element. |
| children | ReactNode | — | Title text content. |
CardDescription
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the description element. |
| children | ReactNode | — | Description text content, rendered in muted-foreground. |
CardAction
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the action container. |
| children | ReactNode | — | Action content (typically a Button), positioned top-right in the header. |
CardContent
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the content section. |
| children | ReactNode | — | Main content of the card. |
CardFooter
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | Additional CSS classes for the footer section. |
| children | ReactNode | — | Footer content, typically action buttons. |