Design system / Molecules
Molecule / Presentation
Card
Card groups caller-supplied content through header, title, description, action, content and footer parts. Its elevation prop selects semantic shadow depth. Content semantics and workflow behavior remain with the caller.
Live example
Current component with fictional data. Example changes are not persisted.
One content concern
Consumer-supplied heading semantics.
Responsibility
Card parts group one content unit through a shared layout and surface contract. The caller supplies semantics and actions. A manager placed inside Card retains its coordination responsibilities and does not become a molecule.
Public contract
The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.
| Prop / part | Type | Requirement | Responsibility |
|---|---|---|---|
| className / children / native props | React.ComponentProps<"div"> | Each part | Consumer supplies content and semantics; depth uses the separate elevation prop, with no data API. |
| elevation | flat | raised | floating | overlay | Card · default raised | Selects semantic shadow depth without changing geometry or child contracts. |
| CardAction | Header child | Optional | Header detects its data-slot and arranges a second column. |
API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.
State and behavior
Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.
No state or hooks. Content, actions, loading, failure and meaning remain consumer-owned.
Dependencies
- Native div elements
- cn()
- CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter
Token and styling contract
These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.
bg-card / text-card-foreground / border / shadow-elevation-*- Container roles.
text-muted-foreground / text-sm- Description utilities.
rounded-xl / gap-6 / py-6 / px-6- Local container and part geometry.
Boundaries and limitations
- CardTitle is a div, not a semantic heading. Choose meaningful heading structure in the consumer.
- Elevation controls depth only; no click, selected, loading or disabled behavior is built in.
- Nested workflows retain their own taxonomy; not every card is a molecule.
Where to make a change
Change shared container/slot geometry in card.tsx; change content and actions in the consumer. Title semantics and overrides need consideration across callers.
Selected real uses
EmptyStateCard
Composes Card parts with a dashed surface and spacing overrides, and uses its own h2 instead of CardTitle. Local overrides can change how shared Card updates appear.
src/components/ui/empty-state-card.tsxThese traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.
Usage contract
import { Card, CardHeader, CardContent, CardFooter } from "@/components/ui/card";
<Card><CardHeader><h2>{title}</h2></CardHeader>
<CardContent>{content}</CardContent><CardFooter>{footer}</CardFooter>
</Card>Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.