AnimatedNumber
Animated number that counts up like an odometer.
A faithful port of Motion+'s AnimateNumber: each digit is a full 0–9 column
that rolls through the intermediate numerals to its new value (a FLIP spring
on y), the leading digit rolls up from zero as magnitude grows, and section
widths animate so proportional fonts stay aligned. Formatting (grouping,
fraction digits, currency, sign) comes from Intl.NumberFormat; the token
duration / easing drive the timing, or pass transition for a bespoke
curve/spring. Use prefix / suffix for units and currency so they align
with the digits and fold into the single screen-reader announcement.
materials indexed
Usage
import { AnimatedNumber, AnimatedNumberProps } from "@desk/ui/components/animated-number";Best practices
Needs
ReducedMotionProviderin the app tree — it supplies the LazyMotiondomMaxfeatures the digit roll and layout animations require, and itsreducedMotion="user"makes the number snap to its final value for users who ask for less motion.Use
prefix/suffixfor units and currency ($,/10), not sibling text nodes — they're layout-animated with the digits and folded into the one screen-reader announcement.Reach for the
duration/easingtokens over a rawtransition— token timing keeps it in step with the rest of the motion system; drop totransitiononly for bespoke springs.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | The number value to display and animate | |
| duration | "instant" | "quick" | "snappy" | "normal" | "swatchFan" | "swatchFanOpen" | "swatchFanExit" | "moderate" | "slow" | Duration token from | |
| easing | "snappy" | "swatchFan" | "smooth" | "customIn" | "customOut" | "customExpand" | "customGentle" | Easing token from | |
| masked | boolean | Wraps the digits in a blur-vignette mask so they fade in and out at the
top/bottom (and left/right) clipping edges — softening the roll for large
display numbers. Uses | |
| prefix | string | Static text rendered before the number, e.g. "$". Layout-animated. | |
| suffix | string | Static text rendered after the number, e.g. "/10". Layout-animated. | |
| locales | Intl.LocalesArgument | BCP-47 locale(s) passed to Intl.NumberFormat. | |
| format | NumberFormat | Intl.NumberFormat options (grouping, fraction digits, currency…). | |
| transition | Transition | Overrides the token-derived timing entirely, applied to the digit roll,
layout and opacity. Accepts any motion |
Also exports
- interface
AnimatedNumberProps
Composition
Used by