Card
Card — a bounded block of related content: media, header, body, footer.
Examples
Quarterly report
Published this morning
Revenue by region, with the year-on-year comparison.
<article class="card">
<div class="card-header">
<h3 class="card-title">Quarterly report</h3>
<p class="card-subtitle">Published this morning</p>
</div>
<div class="card-body">
<p>Revenue by region, with the year-on-year comparison.</p>
</div>
<div class="card-footer">
<button class="btn btn-sm" type="button">Open</button>
</div>
</article>The card sets no width — not a max-inline-size, not a breakpoint.
How wide it is depends on the grid it sits in, and that is the page’s business. .card-footer takes margin-block-start: auto, so in a row of unequal cards every footer still lands on the bottom edge.
Tokens 13
Level 2, declared on .card itself. Set any of them on that selector to restyle this component without touching the skin.
| Token | Default |
|---|---|
| --card-inner-radius | max(0px, calc(var(--card-radius) - var(--card-border-width))) |
| --card-media-aspect-ratio | auto |
| --card-bg | var(--color-surface-raised) |
| --card-border-color | var(--color-border) |
| --card-border-width | var(--border-width) |
| --card-color | var(--color-on-surface) |
| --card-divider-color | var(--color-border-subtle) |
| --card-gap | var(--space-3) |
| --card-padding | var(--space-4) |
| --card-radius | var(--radius-box) |
| --card-shadow | var(--elevation-0) |
| --card-subtitle-color | var(--color-on-surface-muted) |
| --card-title-font-size | var(--font-size-base) |
Variants and states
Variants
.card-lg.card-quiet.card-raised.card-sm.card-sunken
Inside it
.card-link.card-media.card-body.card-footer.card-header.card-subtitle.card-title
State it reads
Read from the platform, never mirrored into a class that could disagree with it.
:focus:hover
Before you ship it
What you have to do 3 requirements
.card-titleis not a heading. Put it on a real<h2>/<h3>at the level the page's outline calls for, or the card is a paragraph in bold to everything that reads structure.- Every image needs an
alt. A decorative card image takesalt=""; one that carries meaning the text does not repeat takes a description. - A clickable card needs
.card-linkon a real<a href>, and exactly one action in the card. See above.
src/css/components/card.css · npx mostlycss add card