Card
A padded surface with a shadow. The classless build styles every
article this way; .card in 1.x meant the bordered
variant, which is now .card-border.
| Class | Does what |
|---|---|
card | Padded, raised surface with a shadow |
card-border | Flat surface with a border instead of a shadow |
card-actions | Footer row: top border, right-aligned actions |
Basic
<article class="card prose">
<h3>Card heading</h3>
<p>Cards hold a block of related content.</p>
</article>
<article>
<h3>Card heading</h3>
<p>Cards hold a block of related content.</p>
</article>
With a footer
<article class="card prose">
<h3>Delete this project?</h3>
<p>This cannot be undone.</p>
<footer class="card-actions flex" style="justify-content: end">
<button class="btn btn-secondary">Cancel</button>
<button class="btn">Delete</button>
</footer>
</article>
<article>
<h3>Delete this project?</h3>
<p>This cannot be undone.</p>
<footer class="flex" style="justify-content: end">
<button class="secondary">Cancel</button>
<button>Delete</button>
</footer>
</article>
Bordered
<div class="card-border prose">
<h3>Bordered</h3>
<p>A border instead of a shadow, on the page background.</p>
</div>
<div class="card-border">
<h3>Bordered</h3>
<p>A border instead of a shadow, on the page background.</p>
</div>
In 1.x, .card was the bordered variant. Both builds now share one
set of class names, so .card is the base card and the bordered one is
.card-border.
Composition
Common ways to put this together with other components. The general rules are on Composition.
A grid of equal cards and a call to action
Several offers of equal weight, then one card that asks for the next step.
<section class="prose">
<h2>Services</h2>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: var(--padding); margin-bottom: 1rem">
<article class="card"><h3>First service</h3><p>What it is, in a line.</p></article>
<article class="card"><h3>Second service</h3><p>What it is, in a line.</p></article>
<article class="card"><h3>Third service</h3><p>What it is, in a line.</p></article>
</div>
<article class="card" style="text-align: center">
<p>Not sure which fits?</p>
<a href="#" class="btn">Talk it through</a>
</article>
</section>
- Layout: a grid with
min(100%, 16rem)columns: as many as fit, one on a phone, and never wider than the screen. - Spacing:
.prosedoes not space adiv, so the grid carries its own1rembottom margin before the call to action.
Bordered items in a raised card
A card holding a few bordered blocks: the blocks drop back to the page colour, which separates them without a second shadow.
<article class="card prose">
<h3>Downloads</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: var(--padding)">
<div class="card-border"><strong>Logo</strong><p class="flex"><a href="#" class="link">SVG</a> <a href="#" class="link">PNG</a></p></div>
<div class="card-border"><strong>Flyer</strong><p class="flex"><a href="#" class="link">PDF</a></p></div>
</div>
</article>
- Surface: surfaces are solid, so a
.cardinside a.cardwould be invisible..card-borderis the nested surface.
A list of linked entries
Each entry is one link: an image beside its title and a sentence.
<div style="display: grid; gap: var(--padding)">
<a href="#" class="semantic card flex flip" style="align-items: center">
<div style="width: 10rem; flex-shrink: 0; aspect-ratio: 1.5; border-radius: var(--border-radius); background: var(--fill-strong)"></div>
<div class="prose"><h3 class="link">Entry title</h3><p>A sentence or two about it.</p></div>
</a>
<a href="#" class="semantic card flex flip" style="align-items: center">
<div style="width: 10rem; flex-shrink: 0; aspect-ratio: 1.5; border-radius: var(--border-radius); background: var(--fill-strong)"></div>
<div class="prose"><h3 class="link">Another entry</h3><p>A sentence or two about it.</p></div>
</a>
</div>
- Actions: the anchor is the card:
.cardand.flexcome after.semanticin the cascade, so the surface and the row survive its reset. - Layout: on a phone
.flipputs the image above the text.
Work in progress
A card that reports progress, with a way out.
<article class="card">
<div class="flex" style="justify-content: space-between">
<strong>Uploading photos</strong>
<span class="text-secondary">7 of 12</span>
</div>
<progress class="progress" value="7" max="12" style="margin: calc(var(--padding) / 2) 0"></progress>
<footer class="card-actions flex" style="justify-content: end">
<button class="btn btn-secondary">Cancel</button>
</footer>
</article>
- Text: the count is
.text-secondaryso the label leads. - Actions: the only action while it runs is a way out, so it is secondary.
Loading
While a grid of cards loads, each card shows blocks where its content will be.
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: var(--padding)" aria-busy="true">
<div class="card">
<div class="skeleton" style="aspect-ratio: 1.5; margin-bottom: calc(var(--padding) / 2)"></div>
<div class="skeleton" style="height: 1.2rem; width: 70%; margin-bottom: calc(var(--padding) / 4)"></div>
<div class="skeleton" style="height: 1rem"></div>
</div>
<div class="card">
<div class="skeleton" style="aspect-ratio: 1.5; margin-bottom: calc(var(--padding) / 2)"></div>
<div class="skeleton" style="height: 1.2rem; width: 55%; margin-bottom: calc(var(--padding) / 4)"></div>
<div class="skeleton" style="height: 1rem"></div>
</div>
</div>
- Surface: the skeletons sit inside the same
.cardthe loaded content will use, so nothing jumps when it arrives. - Layout: skeletons have no size of their own; give them the size of what they stand in for.