Dependency-free animated number text for React counters, prices, stats, OTP slots, and compact metrics.
npm install numerareact is the only peer dependency.
import Numera from 'numera';
import 'numera/style.css';
<Numera value={123456} />;Use Intl.NumberFormat options for currency, compact notation, percentages, signs, decimals, and locale-aware separators:
<Numera
value={79187}
locales="en-US"
format={{ style: 'currency', currency: 'USD' }}
/>;
<Numera
value={3300000}
format={{ notation: 'compact', maximumFractionDigits: 1 }}
suffix=" views"
/>;Numera animates formatted number parts as first-class pieces. Digits roll, separators move, and symbols like $, ,, ., %, +, -, compact labels, prefixes, and suffixes can enter, exit, or crossfade with the number.
<Numera
value={temperature}
format={{ signDisplay: 'exceptZero', maximumFractionDigits: 1 }}
suffix=" deg"
/>;Use presets for quick tuning:
<Numera value={score} preset="soft" />;
<Numera value={score} preset="snappy" />;
<Numera value={score} preset="springy" />;Or pass timing options directly. Springs are generated as CSS timing functions, so there is no runtime animation dependency.
<Numera
value={score}
timing={{
duration: 420,
spring: { mass: 1.2, stiffness: 150, damping: 19 },
}}
/>;Use Numera directly for OTP and code-input slots. Give each slot a stable width, disable layout correction, and pass animationKey when the visible state changes even if the displayed number is still 0.
const digit = code[index] ?? '';
const isFilled = digit.length > 0;
const displayDigit = isFilled ? Number(digit) : 0;
<Numera
value={displayDigit}
preset="soft"
trend={isFilled ? 'up' : 'down'}
animationKey={`${isFilled ? 'filled' : 'empty'}:${displayDigit}`}
layoutCorrection={false}
/>;import { NumeraController } from 'numera/vanilla';
import 'numera/vanilla.css';
const numera = new NumeraController({
element: document.querySelector('[data-numera]')!,
value: 1284,
});
numera.update(1300);See the full docs draft for API details, timing options, examples, and notes for specific use cases.
Please report security issues privately using the guidance in .github/SECURITY.md.
Install dependencies:
npm installRun the playground:
npm run devRun checks:
npm run checkBuild the package:
npm run buildYou might also like:
- number-flow - Animated number component by Maxwell Barvian.
- torph - Dependency-free animated text morphing.
MIT.