Number Roll
Number Roll
Numbers that move with their value. Each changing digit rolls into place, with support for currency, compact notation, and live counters.
Dependencies
Interaction states
- Rolling — Changed digits roll to their next value; unchanged places stay still.
- Growing — Additional digit places open when the value grows.
- Shrinking — Places no longer needed collapse from the number.
- Initial count-up — Supply from to animate from a starting number after mount.
Installation
Add this component with your preferred package manager.
pnpm dlx shadcn@4.21.5 add @cavemio/number-rollFirst 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
Pricing pages
Animate a price when the billing period or plan changes.
Live dashboards
Keep changing metrics readable as new data arrives.
Landing page stats
Roll a number from an initial value when the component mounts.
Countdowns and timers
Use a fixed downward direction for decreasing values.
What it handles
- Digits follow the value — Each column rolls in the direction the number moves.
- Room for another digit — New places expand into the number and removed places fold away.
- Formatting built in — Pass Intl.NumberFormat options for currency, percentages and compact values.
- Real text underneath — Assistive technology and copy-and-paste receive the formatted value.
Usage
Demo values are local; no network requests.
import { NumberRoll } from "@/components/number-roll";
<NumberRoll value={1248} locales="en-US" />
<NumberRoll
value={49}
format={{ style: "currency", currency: "USD" }}
/>Props
| Prop | Type | Description |
|---|---|---|
| value | number | The number to display. |
| format | Intl.NumberFormatOptions | Currency, percent, decimals, compact notation or grouping. |
| locales | string | string[] | Locale used to format the number. |
| prefix / suffix | string | Text placed before or after the formatted number. |
| from | number | Optional starting value for the initial count-up. |
| duration | number · 900 | Roll duration in milliseconds. |
| direction | "up" | "down" | Override the direction inferred from value changes. |
Accessibility & motion
The full formatted value is available as real text to screen readers. Decorative digit columns are hidden. Tabular figures keep the digits aligned; reduced motion disables digit rolling.
pnpm dlx shadcn@4.21.5 add @cavemio/number-roll