What this thread does
The problem
A dashboard KPI card jumps from 1,204 to 1,311 when the data refetches, or an agent writes a setInterval count-up that restarts on every render, reformats badly (no commas, wrong decimals) and ignores users who asked for less motion.
What the source says
NumberFlow by Maxwell Barvian (MIT licence, React package @number-flow/react, latest release number-flow@0.6.2 in July 2026) documents these points on its site:
<NumberFlow value={value} format={{ style: 'currency', currency: 'USD' }} suffix="/mo" />.formattakesIntl.NumberFormatoptions andlocalestakes the usual locale argument, so currency, percent and compact notation work, and prefix and suffix text is supported.trenddecides digit direction: +1 always up, -1 always down, 0 each digit by its own change. The default follows the sign of the change.animated={false}turns animation off.respectMotionPreferencedefaults to true, so users with reduced motion get no animation.useCanAnimateis a hook returning whether animation is possible.willChange(default false) helps when the number changes often or you see repositioning after a transition; the docs warn that overuse costs memory.- Wrap numbers whose width changes each other's layout in
<NumberFlowGroup>so their transitions stay in sync.isolateseparates a transition from other layout changes. - The docs say backgrounds and borders do not scale smoothly during transitions and suggest Motion for those cases.
- For SSR with a strict CSP, a
nonceprop and exported style strings are available.
Prompt to try (mine, not tried)
"In the KPI cards, replace the plain number with NumberFlow from @number-flow/react. Pass the raw number and use format for currency or percent; do not pre-format to a string. Do not animate on first render of a skeleton; show the skeleton, then render NumberFlow with the loaded value. Keep respectMotionPreference at its default."
Common mistakes
- Passing a formatted string such as "$1,204" instead of a number: there is nothing to animate.
- Re-keying the component (
key={Date.now()}) so it remounts and replays from zero. - Animating numbers that update many times per second; show them plain or throttle the data.
- Setting
willChangeeverywhere.
Not verified
I read the docs and repository metadata; I did not install or run it. A trial should check that digits do not shift neighbouring layout in your card design.
Sources
Checked against primary sources:
- NumberFlow docs:
format(Intl.NumberFormat options),locales, prefix and suffix,trend(+1, -1, 0, default sign of the change),animated,respectMotionPreference(default true),useCanAnimate,willChange(default false, memory warning),NumberFlowGroup,isolate,nonce, and the note that backgrounds and borders do not scale smoothly (Motion suggested) all match. - barvian/number-flow repository metadata: MIT; release
@number-flow/react@0.6.2published 18 July 2026.
Not checked here: the sample prompt and the "common mistakes" list are our own advice, not from the docs; nothing was installed or run.
Started from a post by @Maxwell Barvian, packaged by the editor. Original post