Animated Number
Data Display
Motion
A formatted number whose digits roll to the new value when it changes. Built on Intl.NumberFormat, so currency, percent and compact notation roll too.
Preview
Change the value and each digit rolls to its place
1,284
Formats
Pass Intl.NumberFormat options and a locale; separators and symbols stay put
Currency, nl-NL
€ 48.250,75
Percent
24.6%
Compact
1.3M
Fixed decimals
182.4 ms
In Statistic and StatCard
Statistic has an animated prop; StatCard takes any node as its value
Active users
1,284
+4.2%
Revenue this month
€ 48.251+12%
Props
Component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
value* | number | — | The number to show. Digits roll when it changes |
locales | string | string[] | 'en-US' | Locale for Intl.NumberFormat. Fixed by default so server and browser render the same text |
format | Intl.NumberFormatOptions | — | Decimals, currency, percent, compact notation and other Intl options |
className | string | — | Additional CSS classes |
Usage
Import and implementation examples
import { AnimatedNumber } from '@/components/ui/animated-number'
// Plain number: 1,284<AnimatedNumber value={count} />
// Currency in Dutch notation: € 48.250,75<AnimatedNumber value={revenue} locales="nl-NL" format={{ style: 'currency', currency: 'EUR' }}/>
// Percent with one decimal: 24.6%<AnimatedNumber value={0.246} format={{ style: 'percent', minimumFractionDigits: 1 }} />
// Inside a Statistic<Statistic title="Active users" value={count} animated />Features
Built-in functionality
- Rolling digits: Each digit rolls on the Breath ease-out curve over --duration-slower
- Stable columns: Columns are keyed by place value, so 999 to 1,000 rolls the existing digits and adds one
- Intl formatting: Currency, percent, compact and locale separators via Intl.NumberFormat
- No layout shift: Tabular figures keep every digit the same width while it rolls
- SSR safe: Nothing moves on the first render, so hydration shows the final value
Accessibility
Accessibility considerations
ARIA Attributes
The formatted value is in the DOM once, as visually hidden textThe rolling digit strips are aria-hiddenKeyboard Navigation
| Key | Action |
|---|---|
| N/A | AnimatedNumber is not interactive |
Notes
- Screen readers read the final value, never the digits in between
- Copy and paste gives the formatted number; the strips are not selectable
- Under prefers-reduced-motion the digits change without rolling
- It does not announce changes; wrap it in a live region if updates matter