Skip to content
Premium & Brand

Animated Number

Number that springs to its target — counts up or down.

Import

tsx
import { AnimatedNumber } from "@cooud-ui/ui";
bash
npx cooud-ui add animated-number

Examples

API Reference

Generated from the component's exported types.

AnimatedNumberProps

Extends Omit<React.ComponentPropsWithoutRef<typeof motion.span>, "children">

PropTypeDefaultDescription
value*
numberTarget value. Whenever it changes, the number tweens from its current displayed value to here.
format
(n: number) => stringCustom formatter for the displayed string. When omitted, the value is formatted with `Intl.NumberFormat(locale, formatOptions)`.
locale
stringLocale passed to the default `Intl.NumberFormat` formatter (ignored if `format` is set).
formatOptions
Intl.NumberFormatOptionsOptions passed to the default `Intl.NumberFormat` formatter (ignored if `format` is set).
duration
number0.8Tween length in seconds. Defaults to ~0.8s; overrides the spring's natural duration.
spring
AnimatedNumberSpringOverride the settle spring (advanced — defaults to the Cooud count spring).
reducedMotion
"user" | "always" | "never""user"How `prefers-reduced-motion` is honoured. Defaults to `"user"` (snap for users who opt out). Pass `"never"` to always animate the count — e.g. a showcase that must demonstrate it — or `"always"` to force the snap.
announce
booleanfalseAnnounce the **settled** value to screen readers via a visually-hidden `aria-live="polite"` sibling. Defaults to `false`. Only the final value (once the tween completes / snaps) is announced — never the ~97 interpolated frames — so opting in stays quiet.