Card
Groups the content and actions about one thing, such as a plan or a source.
When to use
- Group the content and actions about one thing: a workspace, a source, a plan.
- Show options side by side, with one of them selected.
When not to use
- A row in a list of similar things: use Item.
- Rows and columns of data: use Table.
- A message about the state of the page: use Alert.
Install
npx shadcn@latest add @clinia/cardJane Cooper, 42. Stable vitals, follow-up scheduled for next Tuesday.
Marketing (Sera)
Jane Cooper, 42. Stable vitals, follow-up scheduled for next Tuesday.
Anatomy
Synced today.
- 1Container
[data-part=card]bg-card · border-border · rounded-lg - 2Header: title and description
[data-part=header]text-lg · text-muted-foreground - 3Content
[data-part=content]p-6 pt-0 - 4Footer
[data-part=footer]gap-3 · p-6 pt-0
Clinia rules
defaultis theborderhairline. It is decorative, so it never carries meaning on its own.emphasisis a Trust border (at least 3:1 in both themes) for the selected or featured card. Keep one per group.interactiveis for a card that is itself the link or button: its edge darkens toborder-inputon hover, and focus shows the Trust ring.- Don't nest cards. Split the content inside one card with Separator or spacing.
Cardhas no padding of its own:CardHeader,CardContentandCardFootercarry it. Put content in those parts, or pad a custom child yourself.
Do and don't
3 sources
12 clinicians
States: product (Luma)
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
States: marketing (Sera)
Focus cells apply the component's focus-visible classes statically. Toggle the site theme to review both themes.
Accessibility
Built in
- The default hairline is decorative. The
emphasisborder is Trust, which clears 3:1 on the page and on cards in both themes. variant="interactive"is for a card that is itself a link or button. Card renders adivby default, so the focus ring only shows once it renders a link or you make it focusable (see Your responsibility).
Your responsibility
CardTitlerenders adiv. Put a heading inside it, such as<h3>, so screen reader users can jump from card to card.- A selected card needs a state a screen reader can hear, such as a checked radio button inside it. The border alone says nothing.
- Render an
interactivecard as its link:render={<Link href="…" />}. Otherwise give itrole,tabIndex={0}and Enter handling. - A card that stands on its own, such as a feature card on a marketing page, can keep its
<article>role: passrender={<article />}.
How to test
- Toggle the site theme: the emphasis border stays visible on the page in both.
- With a screen reader, list the headings: each card's title is there.
- On an
interactivecard, press Tab: the Trust ring appears, and Enter opens it.
API
| Prop | Values | Default | Description |
|---|---|---|---|
| render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}> | – | The element to render, such as |
| variant | defaultemphasisinteractive | default |
|
All other props come from the native div element.