Stats band
Stats band
Numbers that arrive when you do: fine lines draw themselves, then each figure rolls up from zero in turn.
Dependencies
Interaction states
- waiting — Off screen: quiet zeros and undrawn lines, so nothing has already happened by the time you arrive.
- arriving — At half visible, the dividers draw over 700ms, then each stat rolls up from 0 (1.2s), 140ms after the one before.
- done — The real numbers. Change a value later and only its changed digits roll.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/stats-bandFirst install? Configure @cavemio once
Run npx shadcn@4.21.5 init if shadcn is not set up, then merge this entry into the registries field in your existing components.json. Keep your other settings and registries.
{
"registries": {
"@cavemio": "https://registry.cavemio.dev/r/cavemio-{name}.json"
}
}Where it’s used
Landing page proof
The row of numbers that shows customers, uptime or volume.
About pages
Company numbers that arrive as the visitor scrolls.
Case studies
Results such as time saved or revenue gained.
Launch and year-in-review pages
A recap of what happened, in figures.
What it handles
- It waits until you arrive — It runs once, the first time half the band is visible. Before that it shows quiet zeros and undrawn lines.
- The lines draw first — The fine lines between the stats draw themselves from the middle out.
- Numbers roll in turn — Each figure rolls up from zero a beat after the last, as its label rises in.
- Any format — Compact numbers like 12.5K+, decimals like 99.98%, and prefixes and suffixes.
- Updates later — Change a value afterwards and only its changed digits roll.
- Real figures for screen readers — It is a description list with the real numbers as text, so search and assistive tech see them straight away.
Usage
Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.
import { StatsBand } from "@/components/stats-band";
<StatsBand
stats={[
{ value: 12480, label: "Teams shipping", format: { notation: "compact" }, suffix: "+" },
{ value: 99.98, label: "Uptime", suffix: "%" },
]}
/>Props
| Prop | Type | Description |
|---|---|---|
| stats | { value; label; format?; prefix?; suffix? }[] | – · Each figure and its label. format takes Intl.NumberFormat options. |
| stagger | number | 140 · Time between one stat starting and the next (ms). |
| numberClassName | string | – · Size and weight of the figures. |
Accessibility & motion
- A description list: each label is a dt and its figure a dd, with the real number as text for screen readers and search. - It runs once, the first time half the band is visible, using an IntersectionObserver; no scroll listeners. - Installs Number roll alongside it. - With reduced motion the numbers and lines are simply there.
pnpm dlx shadcn@4.21.5 add @cavemio/stats-band