Card
A container used to display content in a box, resembling a physical card. Compose a Card.Body, with an optional Card.Header and Card.Footer, inside Card.Root.
When to use
- Group related content in a raised box, with an optional header and footer.
- Prefer
Wellwhen the content is secondary and sits inset in the page, such as a code sample, a note, or a read-only summary. - Prefer
Separatorwhen adjacent content needs a divider and no box. - Prefer
MediaObjectwhen an icon or a figure sits beside a block of text, with no border.
Header and footer
Add a Card.Header with a Card.Title to name the card, and a Card.Footer for actions or a summary. Each one is optional.
Composition
Compose the parts of a Card together to build your own:
Polymorphism
Every Card part accepts an asChild prop. When true, the part renders its single child instead of its default element, forwarding all class names, data-* attributes, and the ref onto that child. Reach for this when a card part should also be a more semantic element: for example, rendering Card.Title as an h2 to fit the surrounding document outline.
API Reference
Card.Root
A container that displays content in a box resembling a physical card. The root component of all Card sub-components.
All props from div, plus:
Card.Body
The main content of a card. Usually composed as a direct child of Card.Root.
All props from div, plus:
Card.Footer
The band below Card.Body. Unless it is the first child, it draws a top border dividing the two. Pass it as a direct child of Card.Root.
All props from div, plus:
Card.Header
The band above Card.Body that holds Card.Title. Pass it as a direct child of Card.Root.
All props from div, plus:
Card.Title
The heading inside Card.Header. Renders an h3 by default. Pass asChild to fit the surrounding document outline. Keep it a heading element (h1-h6) for accessibility.
All props from h1-h6, plus: