Skip to content
Cojeev UI

Animated number

Typography

A smooth, interruptible number transition for totals, metrics and small moments of progress.

React · copy into your project · light and dark themes

Try it

Loading preview…

Take it with you

Copy the example, API and usage notes for your editor or AI assistant.

Add to your project

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/animated-number.json

The command includes the component’s shared dependencies. Your project keeps editable source files.

Include the complete example

This example also composes button, typography. Install its parts together:

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/animated-number.json https://luv-jeri.github.io/cojeev-ui/r/button.json https://luv-jeri.github.io/cojeev-ui/r/typography.json

Using animated number

  • Pass a numeric value; updates animate from the current displayed value. The initial render shows the actual total. Non-finite values show the fallback (an em dash by default), never a fabricated zero.

  • Use locale and format for currency, percentages or compact notation. Reserve enough width for the largest expected value.

  • Use an external live status only when the update needs announcing.

API

Compose the exported parts below. The prop types are read from the React source during the registry build.

Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.

AnimatedNumberProps

PropTypeRequired
valuenumberYes
localestringNo
formatIntl.NumberFormatOptionsNo
duration

Transition time in milliseconds, bounded to 0–2000 and scaled by Flow speed.

numberNo
treatment

Count through values, roll each digit, or count in twelve drawn poses.

"count" | "roll" | "steps"No
from

Optional starting value for the first visible entrance. SSR always shows the final value.

numberNo
fallback

Text for NaN or infinite values; never presents missing data as zero.

stringNo

Accessibility

  • Assistive technology receives the final formatted value without every intermediate animation frame.

  • Reduced motion, global Off and offscreen updates settle immediately.

States and appearance

restupdatingreduced motion

For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.

Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.