Skip to main content

card

Displays a card with header, content, and footer.

Philosophy

Cards are the universal container for grouped content. We decompose them into Header, Content, Footer, Title, and Description not because every card needs all five, but because real-world cards vary enormously. A pricing card needs a footer; a notification card doesn't. The sub-component pattern lets you compose exactly what you need.

Installation


npx @gentleduck/cli add card

npx @gentleduck/cli add card

Usage

import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
import {
  Card,
  CardAction,
  CardContent,
  CardDescription,
  CardFooter,
  CardHeader,
  CardTitle,
} from "@/components/ui/card"
<Card>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card Description</CardDescription>
    <CardAction>Card Action</CardAction>
  </CardHeader>
  <CardContent>
    <p>Card Content</p>
  </CardContent>
  <CardFooter>
    <p>Card Footer</p>
  </CardFooter>
</Card>
<Card>
  <CardHeader>
    <CardTitle>Card Title</CardTitle>
    <CardDescription>Card Description</CardDescription>
    <CardAction>Card Action</CardAction>
  </CardHeader>
  <CardContent>
    <p>Card Content</p>
  </CardContent>
  <CardFooter>
    <p>Card Footer</p>
  </CardFooter>
</Card>

Component Composition

Loading diagram...

API Reference

Card

PropTypeDefaultDescription
dir'ltr' | 'rtl'--Text direction override. Resolved via useDirection (dir prop -> DirectionProvider -> 'ltr').
classNamestring--Additional CSS classes applied to the card container
childrenReact.ReactNode--Card content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardHeader

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the header
childrenReact.ReactNode--Header content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardTitle

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the title
childrenReact.ReactNode--Title content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardDescription

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the description
childrenReact.ReactNode--Description content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardAction

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the action container
childrenReact.ReactNode--Action content (e.g. buttons, icons)
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardContent

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the content area
childrenReact.ReactNode--Main card content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

CardFooter

PropTypeDefaultDescription
classNamestring--Additional CSS classes applied to the footer
childrenReact.ReactNode--Footer content
...propsReact.HTMLProps<HTMLDivElement>--Additional props to spread to the content div

RTL Support

Direction is resolved through the shared primitives direction module. Use a local dir="rtl" override when the component exposes it, or set DirectionProvider at app/root level for global RTL/LTR behavior.