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
<div class="hss-demo">
<p class="hss-caption">Reporting only — the figures are the whole job.</p>
<div class="hss-strip">
<div class="hss-tile" title="Photos imported into the library this month">
<p class="hss-label">Photos</p>
<p class="hss-figure">1,482</p>
<p class="hss-hint">this month</p>
</div>
<div class="hss-tile" title="Median time to export one photo over the last 24 hours">
<p class="hss-label">Median export</p>
<p class="hss-figure">3.2s</p>
<p class="hss-hint">last 24h</p>
</div>
<div class="hss-tile" title="Share of the library that has a copy in the backup">
<p class="hss-label">Backed up</p>
<p class="hss-figure">98.4%</p>
<p class="hss-hint">of the library</p>
</div>
<div class="hss-tile" title="No photo has been given a star rating yet">
<p class="hss-label">Avg. rating</p>
<p class="hss-figure hss-empty">—</p>
<p class="hss-hint">not rated yet</p>
</div>
</div>
<p class="hss-caption">Same strip, working as the filter. Press a tile to narrow the list; press it again to clear.</p>
<div class="hss-strip hss-strip-live" id="hss-filters" role="group" aria-label="Filter downloads by status"></div>
<ul class="hss-list" id="hss-list"></ul>
<p class="hss-status" id="hss-status" role="status"></p>
</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;
grid-template-columns: 1fr;
/* The whole trick: the 1px gap over the container's border-colored
background IS the separator. Real borders double where tiles meet and
break at the wrap edge; a gap cannot do either. */
gap: 1px;
background: var(--border);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
max-width: 720px;
}
/* Column counts are pinned per breakpoint instead of left to auto-fit, and
each step divides the tile count evenly: four tiles go 4 -> 2 -> 1, never
a partial row. auto-fit can't promise that on its own -- tiles here are
placed by normal grid auto-flow, so a row it can't fill stays in the grid
as empty cells, and an empty cell paints straight through to the
container's own border-colored background, a solid block where no tile
sits. */
@media (min-width: 21rem) {
.hss-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 42rem) {
.hss-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.hss-tile {
background: var(--surface);
padding: 1rem 1.25rem;
margin: 0;
}
.hss-label {
margin: 0;
font-family: var(--mono);
font-size: 0.8125rem;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--dim);
}
.hss-figure {
margin: 0;
font-size: 1.6rem;
font-weight: 700;
line-height: 1.25;
font-variant-numeric: tabular-nums;
color: var(--ink);
}
.hss-empty { color: var(--dim); }
.hss-hint {
margin: 2px 0 0;
font-size: 0.9375rem;
color: var(--dim);
}
.hss-demo { display: flex; flex-direction: column; gap: 0.75rem; max-width: 720px; }
.hss-caption { margin: 0.5rem 0 0; font-size: 0.9375rem; color: var(--dim); }
/* The filtering variation is the same strip; only the tile becomes a
control. Five tiles have no divisor between one and five, so there is no
clean multi-column step in between -- this one pins straight from five
columns to one rather than risk a partial row at two, three, or four. */
.hss-strip-live { gap: 1px; grid-template-columns: 1fr; }
@media (min-width: 42rem) {
.hss-strip-live { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
/* The script fills button tiles with spans, which would otherwise run together
on one line; stacking them matches the reporting tiles. */
button.hss-tile {
display: flex;
flex-direction: column;
font: inherit;
text-align: left;
width: 100%;
cursor: pointer;
border: none;
min-height: 44px;
}
button.hss-tile:hover { background: var(--surface-2); }
/* The strip clips its children to keep the rounded corners, so a focus ring
drawn outside the tile is cut off on every outer edge. Draw it inside. */
button.hss-tile:focus-visible { outline-offset: -3px; }
/* Pressed, not selected: the list below is a consequence of the press, and the
tile stays a toggle that can be pressed again to clear. The tint alone is
too faint to carry the state, so an accent bar along the top carries it. */
button.hss-tile[aria-pressed='true'] {
background: color-mix(in srgb, var(--accent) 14%, var(--surface));
box-shadow: inset 0 3px 0 var(--accent);
}
button.hss-tile[aria-pressed='true'] .hss-figure { color: var(--accent); }
.hss-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.hss-list li {
padding: 0.55rem 0.7rem;
border: 1px solid var(--border);
border-radius: calc(var(--radius) - 4px);
background: var(--surface);
font-size: 0.9375rem;
}
.hss-status { margin: 0; font-size: 0.9375rem; color: var(--dim); min-height: 1.6em; }const DOWNLOADS = [
{ title: 'Bicycle drivetrain teardown', status: 'Done' },
{ title: 'Kiln firing, part three', status: 'Downloading' },
{ title: 'Field recording — marsh at dawn', status: 'Queued' },
{ title: 'Lathe restoration, episode 12', status: 'Done' },
{ title: 'Sourdough hydration tests', status: 'Done' },
{ title: 'Bookbinding: the long stitch', status: 'Queued' }
];
const STATUSES = ['All', 'Queued', 'Downloading', 'Done', 'Failed'];
const filters = document.getElementById('hss-filters');
const list = document.getElementById('hss-list');
const status = document.getElementById('hss-status');
let active = 'All';
// The tiles are built once and only their pressed state changes afterwards.
// Rebuilding them on every press would throw away the focused button, and a
// screen reader would lose the "pressed" announcement along with it.
for (const name of STATUSES) {
// Counts come from the unfiltered set, so a tile never reports the number
// of things the current filter is already hiding.
const count = name === 'All' ? DOWNLOADS.length : DOWNLOADS.filter((item) => item.status === name).length;
const tile = document.createElement('button');
tile.type = 'button';
tile.className = 'hss-tile';
tile.dataset.name = name;
tile.innerHTML = '<span class="hss-label"></span><span class="hss-figure"></span><span class="hss-hint"></span>';
tile.querySelector('.hss-label').textContent = name;
tile.querySelector('.hss-figure').textContent = String(count);
tile.querySelector('.hss-hint').textContent = count === 1 ? 'download' : 'downloads';
tile.addEventListener('click', () => {
active = name === 'All' || active === name ? 'All' : name;
render();
});
filters.append(tile);
}
function render() {
for (const tile of filters.querySelectorAll('.hss-tile')) {
tile.setAttribute('aria-pressed', tile.dataset.name === active ? 'true' : 'false');
}
const shown = active === 'All' ? DOWNLOADS : DOWNLOADS.filter((item) => item.status === active);
list.innerHTML = '';
for (const item of shown) {
const row = document.createElement('li');
row.textContent = item.title + ' — ' + item.status;
list.append(row);
}
if (active === 'All') {
status.textContent = 'Showing all ' + DOWNLOADS.length + ' downloads.';
} else if (shown.length === 0) {
// Filtering to zero gets its own words: an empty list with no reason
// reads as a broken page.
status.textContent =
'No downloads are ' + active.toLowerCase() + ' right now. Press the lit tile again to show all ' + DOWNLOADS.length + '.';
} else {
status.textContent =
'Filtered to ' + active + ': ' + shown.length + ' of ' + DOWNLOADS.length + '. Press the lit tile again to clear.';
}
}
render();Paste this into an agent to rebuild the pattern from scratch.
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. Wrap the container in a normal 1px border with a radius and `overflow: hidden` so the outer edge matches the hairlines.
**Pin the column count per breakpoint instead of reaching for `auto-fit`.** `repeat(auto-fit, minmax(160px, 1fr))` looks like it reflows for free, but it wraps by available width, not by tile count, and tiles here are placed by normal grid auto-flow rather than into their own tracks — so a row it can't fill stays in the grid as empty cells, and an empty cell paints straight through to the container's own border-colored background, a solid block sitting where no tile lives. Choose counts that divide the tile count evenly at every step, so the last row is always full: four tiles step 4 → 2 → 1. A count with no divisor between one and itself, like five, has no clean step in between — pin it straight from five columns to one, or pad the row out to a count that does divide.
Inside each tile: an uppercase label in the mono face at a small size with letter-spacing, the figure large and bold with `font-variant-numeric: tabular-nums` so digits align across tiles, and an optional dimmed hint line under it. Give every tile a `title` attribute stating in plain language what the metric measures, so derived figures explain themselves on hover.
Two rules of honesty. A tile whose value is missing still renders — with a dimmed em dash as its figure and a hint naming the action that would fill it ("not rated yet") — because an omitted tile reads as a missing feature and reflows its neighbours. And never put units in a separate visual channel from the number; keep "3.2s" as one string.
**The second form: make the tiles the filter.** The same strip, with each tile a button carrying `aria-pressed`, narrowing the list beneath it. This is worth reaching for when the figures people read are also the cuts they want — a queue by status, an inbox by state, a run by outcome. It saves a filter row that would otherwise sit directly under a set of numbers naming the same categories.
**Compute the counts from the unfiltered set.** A tile that reports how many rows survive the current filter is a number that changes when you press a different tile, which makes the strip unreadable as a summary. The counts are the census; the filter is a view of it.
Press the lit tile again to clear, and give "All" the same behaviour, so there is always a way back that does not require guessing which control resets. A tile whose count is zero stays in the strip and stays pressable. Filtering to zero is the one case that needs its own words beneath — say which status is empty and how to get the full list back, because a bare empty list reads as a broken page. Put the sentence that describes the current view in a `role="status"` element so the result of a press is announced.
Build the tiles once and change only `aria-pressed` on each press. Re-rendering the strip destroys the button that has focus, which drops keyboard users back to the top of the page and swallows the screen reader's "pressed" announcement.
Do not let the pressed tint carry the state alone — a 14% accent wash is a contrast of about 1.2:1 against the surface. Add an accent bar along the tile's top edge as an inset `box-shadow` (not a border, which would bring back the doubled-edge problem). And because the container clips its children, draw the focus ring inside the tile with a negative `outline-offset`; a ring outside it is cut off along the strip's outer edges.
Use `aria-pressed` rather than tab semantics. The list below is a consequence of the press, not a panel belonging to a tab, and tab roles promise arrow-key movement between panels that this does not have.
Every color comes from theme custom properties, and the strip has to read correctly in both light and dark themes.