Skip to content

Feature blocks and cards

A feature told at length with a picture, or in a card in a grid with an icon, title and line.

<div class="cap-feature" id="fe-stacked">
  <div class="cap-feature-text">
    <p class="cap-eyebrow" data-tone="accent">Checks</p>
    <h3 class="cap-feature-title">Every page checked before it ships</h3>
    <p class="cap-feature-body">Links, headings and images are checked on every save, and a failing required check holds the publish.</p>
  </div>
  <div class="cap-feature-media"><p class="feature-demo">Preview: 3 checks passing on example.com</p></div>
</div>

Installation

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

Usage

<div class="cap-features" data-alternate>
  <div class="cap-feature" data-layout="beside">        <!-- data-variant="lifted", data-align="start" -->
    <div class="cap-feature-text">
      <p class="cap-eyebrow" data-tone="accent">Recovery</p>
      <h3 class="cap-feature-title">Title</h3>
      <p class="cap-feature-body">Paragraph.</p>
    </div>
    <div class="cap-feature-media">
      <div class="cap-feature-scroll" role="region" aria-label="Sample queue" tabindex="0">[preview]</div>  <!-- tall only -->
    </div>
  </div>
</div>

<ul class="cap-feature-grid">
  <li class="cap-feature-card">
    <span class="cap-feature-card-icon" aria-hidden="true"><svg>...</svg></span>
    <h3 class="cap-feature-card-title">Failed invoices</h3>
    <p class="cap-feature-card-text">One line.</p>
  </li>
  <li class="cap-feature-card">                       <!-- a tag at the end of the title's line -->
    <div class="cap-feature-card-head"><h3 class="cap-feature-card-title">Retry schedule</h3><span class="cap-feature-card-tag"><span class="cap-pill">Recovery</span></span></div>
    <p class="cap-feature-card-text">One line.</p>
  </li>
</ul>

Examples

Beside, alternating

<div class="cap-features" data-alternate id="fe-alternate">
  <div class="cap-feature" data-layout="beside">
    <div class="cap-feature-text">
      <p class="cap-eyebrow" data-tone="accent">Drafts</p>
      <h3 class="cap-feature-title">Write where you publish</h3>
      <p class="cap-feature-body">Field notes save as you type.</p>
    </div>
    <div class="cap-feature-media"><p class="feature-demo">Preview: a draft</p></div>
  </div>
  <div class="cap-feature" data-layout="beside">
    <div class="cap-feature-text">
      <p class="cap-eyebrow" data-tone="accent">Review</p>
      <h3 class="cap-feature-title">Ask for a second read</h3>
      <p class="cap-feature-body">Sam Lee gets a link and comments in the margin.</p>
    </div>
    <div class="cap-feature-media"><p class="feature-demo">Preview: two comments</p></div>
  </div>
</div>

Lifted, with a tall preview

<div class="cap-feature" data-variant="lifted" id="fe-lifted">
  <div class="cap-feature-text">
    <p class="cap-eyebrow" data-tone="accent">History</p>
    <h3 class="cap-feature-title">Every change on the record</h3>
    <p class="cap-feature-body">Who changed what, and when.</p>
  </div>
  <div class="cap-feature-media">
    <div class="cap-feature-scroll" role="region" aria-label="Sample change history" tabindex="0">
      <ol class="feature-demo-rows">
        <li>Alex Rivera edited Getting started</li><li>Sam Lee published Spring update</li><li>Jordan Park added Field notes</li><li>Alex Rivera edited Annual report</li><li>Sam Lee edited Release notes</li><li>Jordan Park published Field notes</li><li>Alex Rivera edited Getting started</li><li>Sam Lee edited Spring update</li><li>Jordan Park edited Annual report</li><li>Alex Rivera published Release notes</li><li>Sam Lee edited Getting started</li><li>Jordan Park edited Spring update</li><li>Alex Rivera edited Field notes</li><li>Sam Lee published Annual report</li>
      </ol>
    </div>
  </div>
</div>

Card grid

<ul class="cap-feature-grid" id="fe-cards">
  <li class="cap-feature-card">
    <span class="cap-feature-card-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75"><path d="M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/></svg></span>
    <h3 class="cap-feature-card-title">Broken links</h3>
    <p class="cap-feature-card-text">Every link on every page, checked nightly.</p>
  </li>
  <li class="cap-feature-card">
    <span class="cap-feature-card-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg></span>
    <h3 class="cap-feature-card-title">Scheduled posts</h3>
    <p class="cap-feature-card-text">Set a time and the post goes live on its own.</p>
  </li>
  <li class="cap-feature-card">
    <h3 class="cap-feature-card-title">Without an icon</h3>
    <p class="cap-feature-card-text">The text takes the whole card.</p>
  </li>
  <li class="cap-feature-card" data-product="recovery">
    <div class="cap-feature-card-head"><h3 class="cap-feature-card-title">Retry schedule</h3><span class="cap-feature-card-tag"><span class="cap-pill" data-tone="info">Recovery</span></span></div>
    <p class="cap-feature-card-text">A tag at the end of the title's line.</p>
  </li>
</ul>

API reference

FeatureBlock

PropTypeRequiredDoes
eyebrowReactNode
titleReactNodeYes
bodyReactNode
mediaReactNodeThe picture of the feature working: a preview panel, a screenshot.
scrollLabelstringA tall preview scrolls in a window; this names that window for a screen reader.
layout"stacked" | "beside""stacked": the text centered over the picture. "beside": text and picture side by side when wide.
alignStartbooleanText aligned to the start instead of centered (stacked only).
liftedboolean
headingLevel"h2" | "h3" | "h4"
idstring

Features

PropTypeRequiredDoes
childrenReactNodeYes
alternateboolean

FeatureCard

PropTypeRequiredDoes
iconReactNode
titleReactNodeYes
textReactNode
tagReactNodeA tag at the end of the title's line: a pill naming its product or plan.
idstring
attributesRecord<`data-${string}`, string>The site's own data attributes on the card (a filter's hooks, say). Only data-* names.
headingLevel"h2" | "h3" | "h4" | "p"

FeatureGrid

PropTypeRequiredDoes
itemsFeatureCardItem[]Yes
headingLevel"h2" | "h3" | "h4" | "p"
orderedboolean
labelstring

CSS variables

VariableDefault
--cap-feature-scroll-h30rem
--cap-features-gapvar(--space-9)

Parts and data attributes

ClassIs
.cap-featurethe root
.cap-feature-bodya part
.cap-feature-mediaa part
.cap-feature-scrolla part
.cap-feature-texta part
.cap-feature-titlea part
.cap-featuresits own class
AttributeValues
data-alignstart
data-alternatepresent or absent
data-layoutbeside
data-variantlifted
StateRead from
:focus-visiblethe platform

Accessibility

KeyDoes
TabReaches a tall preview's scrolling window
Arrow keysScroll that window
  • A tall preview is role="region" with a name and a Tab stop.
  • Title --text, paragraph --muted, eyebrow --accent-text: in the contrast report.