# Stats band

> Numbers that arrive when you do: hairlines draw themselves, then each figure rolls up from zero in turn.

A row of big numbers is proof, but a static one gets scrolled past. This band waits until it is on screen. Then the hairlines between the stats draw themselves from the middle out, and each figure rolls up from zero a beat after the last, digit by digit, as its label rises in. Any format works: compact ("12.5K+"), decimals ("99.98%"), prefixes and suffixes. Screen readers get the real figures straight away.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/stats-band.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`
- Docs and live preview: https://hairlineui.com/ui/stats-band
- Registry item (source): https://hairlineui.com/r/stats-band.json

## Usage

```tsx
import { StatsBand } from "@/components/stats-band";

<StatsBand
  stats={[
    { value: 12480, label: "Teams shipping", format: { notation: "compact" }, suffix: "+" },
    { value: 99.98, label: "Uptime", suffix: "%" },
  ]}
/>
```

## In a proof section

Fetch the numbers on the server; the band animates them when the visitor gets there.

```tsx
import { StatsBand } from "@/components/stats-band";

export default async function Proof() {
  const { teams, uptime, rating } = await getPublicStats(); // your data, cached

  return (
    <section className="mx-auto max-w-5xl border-y">
      <StatsBand
        stats={[
          { value: teams, label: "Teams shipping on Relay", format: { notation: "compact", maximumFractionDigits: 1 }, suffix: "+" },
          { value: uptime, label: "Uptime this year", format: { maximumFractionDigits: 2 }, suffix: "%" },
          { value: rating, label: "Average review", format: { minimumFractionDigits: 1 }, suffix: " / 5" },
        ]}
      />
    </section>
  );
}
```

## Props

| Prop | Type | Default | 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. |

## 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.

## What it handles

A row of big numbers is proof, but a static one gets scrolled past. This band waits until it is on screen, then rolls each figure up in turn.

- **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 hairlines 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.

## Replaces

a count-up library, an intersection observer, number formatting, stagger timing, a description list

## Where it fits

- **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.

## Notes

- 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.

License: MIT (https://hairlineui.com/license#components)
