Animated Numbers
An accessible number counter that animates into view with locale-aware formatting, prefixes, suffixes, decimals, delays, and reduced-motion support.
Installation
npx shadcn@latest add @navui/animated-numbersUsage
Pass the final value; add a prefix, suffix, or locale when the number needs context. Screen readers receive the final formatted value.
import { AnimatedNumber } from "@/components/navui/animated-numbers";
export function Example() {
return <AnimatedNumber value={1240} prefix="$" locale="en-CA" />;
}API reference
Custom NavUI component.
| Prop | Type | Default | Description |
|---|---|---|---|
valueRequired | number | — | The final numeric value displayed when the animation completes. |
from | number | 0 | The starting value used before the component enters the viewport. |
prefix / suffix | string / string | "" / "" | Text rendered immediately before or after the formatted number. |
decimalPlaces | number | 0 | The fixed minimum and maximum number of fraction digits. |
duration / delay | number / number | 1 / 0 | Animation duration and start delay in seconds. |
locale | string | "en-US" | Locale passed to Intl.NumberFormat for separators and decimal formatting. |
Accessibility
- The final formatted value is exposed to screen readers; intermediate animation frames are decorative. Respects reduced motion.