Skip to main content

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 Well when the content is secondary and sits inset in the page, such as a code sample, a note, or a read-only summary.
  • Prefer Separator when adjacent content needs a divider and no box.
  • Prefer MediaObject when an icon or a figure sits beside a block of text, with no border.

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:

Card.Root├── Card.Header│   └── Card.Title├── Card.Body└── Card.Footer

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:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card styling onto alternative element types or your own React components.

Card.Body

The main content of a card. Usually composed as a direct child of Card.Root.

All props from div, plus:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Body styling onto alternative element types or your own React components.

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:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Footer styling onto alternative element types or your own React components.

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:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Header styling onto alternative element types or your own React components.

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:

PropTypeDefaultDescription
asChild?booleanfalseUse the asChild prop to compose the Card.Title styling onto alternative element types or your own React components.