Overview
Reference usage
Grid container that lays out multiple stat tiles with consistent spacing and alignment.
Usage
StatisticGroup is a compound component. Import the parent and compose StatisticGroup.Statistic via the namespace API.
The leaf is also a named export of @lostgradient/cinder.
Three statistics
A group of exactly three statistics never lays out as 2 + 1: it goes straight to one column instead. With columns={3} or the default columns="auto" it is three columns above 30rem of content width and one column at or below it, with no two-column step between. A three-statistic auto group in the default variant draws the same dividers as columns={3}: vertical between three columns, horizontal when stacked.
An automatic group of exactly four steps 1, 2, 4 columns and is never 3 + 1: one column below 33rem of content width, two from 33rem, and four from 67rem. Four statistics keep the two-column step in a fixed columns={4} group too, because 2 + 2 is even, and every other count keeps the layout it had. These are CSS quantity queries on the grid's children (:has()), with no script, so they follow the number of statistics that render. In the default variant an automatic group of four draws the same dividers as columns={4} at the equivalent layout: horizontal between stacked statistics below 33rem, a vertical rule at the end of each row of two from 33rem, and vertical rules between all four from 67rem.
In the default variant a divider under a stacked statistic sits midway between two statistics: the gap is split, half above the rule and half below it.
Rendering and customization
The root .cinder-statistic-group receives class, style, and every other prop, carries data-cinder-variant and data-cinder-columns, and is the container that the column-collapse queries measure — so sizing the root (style="inline-size: 20rem", a max-inline-size class) is what makes a fixed column count collapse. The cells render inside an inner .cinder-statistic-group__grid, which owns display: grid, the column template, and the gap. Target that element for layout overrides such as grid-template-columns; a gap override on the root does not reach it, but --cinder-statistic-group-gap set on the root does. Cells are .cinder-statistic inside the grid, so a direct-child selector reads .cinder-statistic-group > .cinder-statistic-group__grid > .cinder-statistic. Each cell spans four of the grid's row tracks as a subgrid (label, value, caption, change), so the stats in one row share those lines: a label that wraps makes its row of labels taller, and every value stays on its neighbours' line.
When to use
- Showing a row of related statistic tiles such as the top metrics of a dashboard.
- Giving a cluster of statistic entries a single accessible group label.
- Setting one quiet stat in the page flow under a spotlight, with variant plain.
- Rendering exactly one metric at full size — use statistic on its own.
- Building a freeform card grid unrelated to numeric metrics — compose surface or grid-list directly.
Examples
Attention dot and caption
An amber attention dot marks a non-zero bad count, and a caption under the value says what the number means in words. A zero count shows neither the dot nor a worry.
Responsive auto columns
Setting `columns` to `auto` switches the grid to CSS auto-fit with minmax, so tiles reflow to fit the available width instead of locking to a fixed column count.
Basic stat group
A row of summary metrics. Uses the StatisticGroup namespace API: StatisticGroup.Statistic renders each metric inside the parent StatisticGroup grid.
Cards variant
The `cards` variant renders each metric as a discrete bordered card, separating the tiles instead of laying them out edge-to-edge in a shared grid.
Compact summary strip
Dense summaries can tune StatisticGroup spacing and Statistic typography through public CSS variables.
Marketing metrics
A landing-page KPI band recipe: Container frames heading copy above StatisticGroup in the cards variant, with fully-worded change labels.
Multi-row group
More metrics than columns, so the grid wraps. The default variant draws a vertical divider between neighbours and suppresses it at the end of each row, and a fixed column count collapses as the group itself narrows.
Plain variant under a spotlight
variant="plain" draws no surface, border, padding or divider and sets its values a step smaller, so one stat sits under a Spotlight without competing with it.
Shadow cards
edge="shadow" swaps the hairline border of each `cards` stat for one soft shadow. A card draws one edge, never both.
Props
Name | Type | Default | Description |
|---|---|---|---|
columns | 1234'auto' | 'auto' | Grid column count. 'auto' uses auto-fit with minmax for responsive layout. |
variant | 'default' | 'cards' | 'shared-borders' | 'plain' | 'default' | Visual variant; surfaced as data-cinder-variant for CSS styling.
- 'default' — the GroupedList's surface (the raised fill, no border, the surface
radius), with dividers between stats when
columns is a fixed count, or 'auto' with exactly three or exactly four statistics.
An auto group of three draws the dividers columns={3} does, and an auto group of four
draws the dividers columns={4} does at the same layout. Any other columns='auto' has
no dividers: an auto-fit grid's column count is unbounded, so CSS cannot tell which cells
end a row.
- 'cards' — each stat gets a card of its own, with the one edge edge names.
- 'shared-borders' — single outer border with 1px gap dividers between stats.
- 'plain' — no surface, border, padding or divider, and values a step smaller, for a
stat or two set in the page flow under a Spotlight without competing with it. |
edge | 'border' | 'shadow' | 'border' | With variant="cards", the one edge each stat's card draws: a flat 'border', or a 'shadow'
with no visible border, as a raised card has. The other variants have their own borders and
ignore it. |
children required | snippet | Statistic children, typically one or more <Statistic> components. | |
label | text | Optional accessible label for the whole stat set. When provided, the
container becomes role="group" and uses this value as its accessible name. | |
role | AriaRole | undefined | null |