← All patterns / layout / hairline-stat-strip
Layout · #15 Updated
Hairline stat strip
A row of stat tiles joined by hairlines that are grid gap, not borders — the container paints the border color and the tiles paint the surface, so separators never double up or break when the row wraps — in a reporting form and in a second form where each tile is the filter for the list beneath it.
Reach for it when building
Summary strip at the top of a detail page
Dashboard KPI row
Account usage overview
Report header figures
Profile stats band
Tags
This whole site is built on the same trick. The nav, the footer and every card grid are rules drawn by structure, not decoration. Toggle X-ray in the nav to see the boxes.
Reporting only — the figures are the whole job.
Same strip, working as the filter. Press a tile to narrow the list; press it again to clear.
- Bicycle drivetrain teardownDone
- Kiln firing, part threeDownloading
- Field recording — marsh at dawnQueued
- Lathe restoration, episode 12Done
- Sourdough hydration testsFailed
- Bookbinding: the long stitchQueued
Showing all 6 downloads.
<div class="hss-strip">
<div class="hss-tile">
<span class="hss-label">Documents</span>
<span class="hss-fig">1,482</span>
<span class="hss-sub">this period</span>
</div>
<div class="hss-tile">
<span class="hss-label">Quality score</span>
<span class="hss-fig is-missing" aria-label="No value">—</span>
<span class="hss-sub">not rated yet</span>
</div>
</div>
<div class="hss-strip hss-filter">
<button type="button" class="hss-tile" data-filter="queued" aria-pressed="false">
<span class="hss-label">Queued</span>
<span class="hss-fig">2</span>
<span class="hss-sub">downloads</span>
</button>
</div>
Colors come from shared theme tokens — --surface, --ink, --border, --accent and friends — so this CSS carries no palette of its own. Use Runnable file to copy the tokens along with it.
.hss-strip {
display: grid;
gap: 1px;
background: var(--border);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
grid-template-columns: 1fr;
}
@media (min-width: 21rem) { .hss-strip { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 42rem) { .hss-strip { grid-template-columns: repeat(4, 1fr); } }
.hss-tile { background: var(--surface); padding: 0.8rem 0.9rem; min-width: 0; }
.hss-label { font: 0.8125rem/1.3 ui-monospace, monospace; text-transform: uppercase; overflow-wrap: anywhere; }
.hss-fig { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hss-fig.is-missing { color: var(--dim); }
.hss-tile[aria-pressed="true"] {
background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
const tiles = [...document.querySelectorAll('.hss-filter [data-filter]')];
const rows = [...document.querySelectorAll('[data-status]')];
tiles.forEach((tile) => {
tile.addEventListener('click', () => {
const wasOn = tile.getAttribute('aria-pressed') === 'true';
tiles.forEach((other) => other.setAttribute('aria-pressed', 'false'));
const status = wasOn ? 'all' : tile.dataset.filter;
if (!wasOn) tile.setAttribute('aria-pressed', 'true');
rows.forEach((row) => {
row.hidden = status !== 'all' && row.dataset.status !== status;
});
});
});
Build a strip of statistic tiles that reads as one joined instrument panel rather than a row of floating cards.
The separators between tiles must not be borders. Make the container a CSS grid with gap: 1px and give the container itself the border color as its background; each tile then paints the surface color on top. The 1px of container showing through the gap is the hairline. This is the entire pattern: real borders double where two tiles meet and leave a stray edge when auto-fit wraps the row, and a gap physically cannot do either.