How it works
Each digit is a window showing one cell of a vertical 0–9 strip, moved to the target with translateY. Neighbouring digits start a few dozen milliseconds apart, from the ones place upward, which reads like a carry. The number waits at 0 until it is in view (IntersectionObserver), then rolls up; later changes roll from the old digit to the new one and never pass back through 0. Tabular digits keep the width steady and a mask fades the top and bottom edges. Pure CSS transitions, no timers. The demo is a live sales card: each new order rolls the total and the delta, grows the current hour's bar and slides into the panel below.
Use it for
- Key figures such as balances, visits or order counts where the change itself matters.
- Dashboards and widgets where numbers should roll in when they first come into view.
Look elsewhere when
- Many numbers changing at once in a table: it looks noisy, just replace the text.
- Live data refreshing several times a second: the animation cannot finish.
Usage
import { RollingNumber } from './RollingNumber.jsx'
export function SalesToday({ total, delta }) {
return (
<div style={{ fontSize: 40, fontWeight: 700, letterSpacing: '-0.03em' }}>
$<RollingNumber value={total} duration={700} />
<small>
<RollingNumber value={delta} decimals={1} />%
</small>
</div>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
value | number | — | The number to show. Rounded to `decimals` places (an integer by default). |
duration | number | 700 | Roll time of each digit, in ms. |
stagger | number | 45 | Delay between neighbouring digits, in ms. |
separator | boolean | true | Adds thousands separators. |
decimals | number | 0 | Digits after the decimal point (0 to 6). Every fraction digit rolls like the others. |
locale | string | 'en-US' | Locale for the separators, for example de-DE for 12.846,5. |
startOnView | boolean | true | Wait at 0 until at least 30% of the number is in view, then roll up. False rolls up as soon as it mounts. |
blur | boolean | false | Softens each digit with motion blur while it rolls, more for a longer roll, and sharpens it as it lands. Good for prices and balances that change on a switch. |
Accessibility
- Screen readers get only the final number through aria-label, never the values in between.
- With reduced motion, the result is shown directly.
- Until it is in view the visible digits rest at 0, but aria-label always holds the real number.
Motion
700ms per digit on the reveal curve (cubic-bezier(0.22, 1, 0.36, 1)), 45ms between neighbouring digits; starts on first view. With blur, each rolling digit takes filter: blur() up to 0.02em + 0.008em per digit travelled (at most 0.08em), peaking at 30% of the roll and sharp again on landing; reduced motion turns it off with the roll.
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 component next to your own.
RollingNumber.jsxrolling-number.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



