Usage
import { StatsBand } from './StatsBand.jsx'
// Every period given in data switches at once. Load others on demand with onPeriodChange:
<StatsBand
locale="en"
periods={[{ id: '30d', label: '30 days', compare: 'vs previous 30 days' }]}
data={{ '30d': [{ id: 'teams', label: 'Teams onboarded', value: 1284, change: 12.4, trend: [880, 960, 1120, 1284] }] }}
loading={!stats}
onPeriodChange={async (id) => (await fetchStats(id)).items}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | Language of the built-in text and number format. |
periods | Array<{ id, label, compare }> | 30 days, 90 days, 12 months | The periods of the segmented control; `compare` is the line under each change. |
data | { [periodId]: Array<{ id, label?, value, decimals?, prefix?, suffix?, change?, better?, trend? }> } | Array<…> | sample numbers | The numbers of each period; a plain array is one period, shown without the period switch. `change` is in per cent; `better: "down"` marks a number that should fall. A period with no numbers shows the empty state. |
period / defaultPeriod | string | the first period | The chosen period, controlled or as a starting point. |
loading | boolean | false | Shows the skeleton of the tiles. |
onPeriodChange | (id) => void | Promise<Array | void> | — | Another period was picked. For a period missing from `data`, resolve its numbers; the tiles dim meanwhile. |
product | string | 'Halden' (sample) | The product’s name, used in the sentence under the title. |
labels | object | — | Replaces any built-in text (keys as in copy.js). |
className | string | — | Added to the root section. |
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.
StatsBand.jsxstats-band.csscopy.jskit.jsxkit.cssui/rolling-number/ui/empty-state/ui/sparkline/ui/skeleton-shimmer/ui/segmented-control/tokens.cssREADME.md
The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.