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

Usage

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.

Animated Numbers properties
PropTypeDefaultDescription
valueRequirednumber—The final numeric value displayed when the animation completes.
fromnumber0The starting value used before the component enters the viewport.
prefix / suffixstring / string"" / ""Text rendered immediately before or after the formatted number.
decimalPlacesnumber0The fixed minimum and maximum number of fraction digits.
duration / delaynumber / number1 / 0Animation duration and start delay in seconds.
localestring"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.