Data Display/Card

Card

Displays a card with header, content, and footer.

Themed

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.

Login to your account
Enter your email below to login to your account

Simple

Basic card with title, description, content, and footer.

Card Title
Card description goes here.

This is the card content. You can put any content here.

With Image

Card with an image header using AspectRatio for consistent sizing.

Healthy food bowl
Healthy Recipes
Nutritious meals for a balanced lifestyle.

Discover our collection of wholesome and delicious meal ideas.

With Action

Card with a header action button using CardAction, positioned top-right.

Notifications
Manage your notification preferences.

Push Notifications

Receive push notifications

Email Updates

Get weekly email updates

Card Grid

Multiple cards in a responsive grid layout for dashboards and navigation.

📊
Analytics
View your analytics dashboard
📄
Reports
Generate and download reports
⚙️
Settings
Configure your preferences

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 onKeyDown with tabIndex={0}

Screen Reader Support

  • Use role="article" for standalone content cards to convey meaning
  • Associate the card with its title using aria-labelledby pointing to the CardTitle id
  • Interactive cards that act as links should have aria-label describing 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>

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

PropTypeDefaultDescription
allowOverflowbooleanfalseAllow content to overflow the card boundaries (useful for dropdowns, menus, etc.).
classNamestringAdditional CSS classes to apply to the card container.
childrenReactNodeCard content, typically composed of CardHeader, CardContent, and CardFooter.

CardHeader

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the header section.
childrenReactNodeHeader content (CardTitle, CardDescription, CardAction).

CardTitle

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the title element.
childrenReactNodeTitle text content.

CardDescription

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the description element.
childrenReactNodeDescription text content, rendered in muted-foreground.

CardAction

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the action container.
childrenReactNodeAction content (typically a Button), positioned top-right in the header.

CardContent

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the content section.
childrenReactNodeMain content of the card.

CardFooter

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the footer section.
childrenReactNodeFooter content, typically action buttons.