Skip to content

Card

One piece of content or one choice, with its picture, heading, text and actions in source order.

<ul class="cap-card-grid">
  <li>
    <article class="cap-card">
      <h3>Field notes</h3>
      <p>What the spring survey found along the creek, with the counts by week.</p>
    </article>
  </li>
  <li>
    <article class="cap-card">
      <hgroup>
        <h3>Annual report</h3>
        <p>Example Co, 2026</p>
      </hgroup>
      <ul>
        <li>Twelve sites</li>
        <li>Four new members</li>
      </ul>
    </article>
  </li>
</ul>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/card.css";

Examples

<ul class="cap-card-grid">
  <li>
    <a href="#getting-started" id="card-link">
      <div class="cap-card" data-ratio="16/9">
        <svg viewBox="0 0 160 90" role="img" aria-label="A bar chart rising left to right"><rect width="160" height="90" fill="var(--sunken)" /><rect x="20" y="50" width="24" height="30" fill="var(--accent)" /><rect x="68" y="35" width="24" height="45" fill="var(--accent)" /><rect x="116" y="20" width="24" height="60" fill="var(--accent)" /></svg>
        <h3>Getting started</h3>
        <p>Set up a site and publish the first post.</p>
      </div>
    </a>
  </li>
  <li>
    <a href="#spring-update">
      <div class="cap-card">
        <h3>Spring update (hover)</h3>
        <p>Three changes to the release schedule.</p>
      </div>
    </a>
  </li>
</ul>

Stretched link with actions

<ul class="cap-card-grid" data-align="rows">
  <li>
    <article class="cap-card" id="card-actions">
      <h3><a class="cap-card-link" href="#release-notes">Release notes</a></h3>
      <p>Every change in the last release, grouped by area.</p>
      <footer>
        <button type="button" class="cap-btn" data-variant="secondary" data-size="sm" id="card-save">Save</button>
        <a href="#release-notes">Read more<span class="cap-sr-only"> about Release notes</span></a>
      </footer>
    </article>
  </li>
  <li>
    <article class="cap-card">
      <h3><a class="cap-card-link" href="#sam-lee">Sam Lee</a></h3>
      <div>
        <p>Editor.</p>
        <p>Writes the monthly roundup and reviews every guest post before it goes out.</p>
      </div>
      <footer>
        <a href="mailto:sam@example.com">Email Sam</a>
      </footer>
    </article>
  </li>
</ul>

Lead

<article class="cap-card" id="card-lead">
  <span class="cap-card-lead">
    <button type="button" class="cap-btn" data-variant="secondary" data-size="sm" id="card-lead-play" aria-label="Play Field notes, episode 4">▶</button>
  </span>
  <header>
    <p>Episode 4 · 32 min</p>
    <h3><a class="cap-card-link" href="#field-notes-4">Field notes, episode 4</a></h3>
  </header>
  <p>Where the samples came from, and what the first plates showed.</p>
  <footer>
    <a href="#tag-fieldwork">fieldwork</a>
  </footer>
</article>

Side layout and a book cover ratio

<article class="cap-card" data-layout="side" data-ratio="2/3">
  <svg viewBox="0 0 120 180" role="img" aria-label="A plain cover"><rect width="120" height="180" fill="var(--accent-soft)" /><rect x="16" y="24" width="88" height="6" fill="var(--accent)" /></svg>
  <header>
    <h3>The Example Handbook</h3>
    <p>Alex Rivera</p>
  </header>
  <p>A guide to the parts every site shares, from the header to the footer.</p>
</article>

Choice

<fieldset class="cap-card-grid" role="radiogroup" aria-labelledby="plan-legend">
  <legend id="plan-legend" class="cap-sr-only">Plan</legend>
  <label class="cap-card">
    <input type="radio" name="plan" value="free" checked />
    <strong>Free</strong>
    <span>One site, the whole reading product.</span>
  </label>
  <label class="cap-card" id="choice-plus">
    <input type="radio" name="plan" value="plus" />
    <strong>Plus</strong>
    <span>Adds the companion.</span>
  </label>
  <label class="cap-card">
    <input type="radio" name="plan" value="team" disabled />
    <strong>Team (disabled)</strong>
    <span>Not offered yet.</span>
  </label>
</fieldset>

API reference

CSS variables

VariableDefault
--card-min16rem
--card-ratio4 / 3
--fs-card-titlevar(--fs-h3)

Parts and data attributes

ClassIs
.cap-cardthe root
.cap-card-grida part
.cap-card-leada part
.cap-card-linka part
.cap-card-mediaa part
AttributeValues
data-alignrows
data-layoutside
data-ratio1 2/3 4/3
StateRead from
:activethe platform
:checkedthe platform
:disabledthe platform
:focus-visiblethe platform
:hoverthe platform

Accessibility

KeyDoes
TabReaches the card's link (one stop for a linked card), then its own actions in order
EnterFollows the link
SpaceChecks a choice card's radio or checkbox; arrow keys move between radios
  • Each card has a heading, so a screen reader can move card to card.
  • A linked card's name is its whole text; use the stretched link when a card has much text.
  • Informative images get alt text; a decorative one gets alt="".