Number Ticker

Animated

A number that animates to its value.

View Source

#Installation

npx @dinachi/cli@latest add number-ticker

#Usage

tsx
import { NumberTicker } from "@/components/ui/number-ticker"
tsx
<NumberTicker value={12480} />

#Examples

#Variants

VariantUse it when
odometerA figure should feel counted rather than printed.
counterThe numbers in between matter, or the format is too complex to split into columns.
flipDeparture boards, scoreboards, anywhere the mechanical reference is the point.

#When to use it

The roll marks an arrival. A value that updates on a timer has already been read and only needs to be correct.

Use it forNot for
A figure landing once: a total, a result, a stat on first paint.A number that changes more than once every few seconds. Pass live and the figure updates instantly, with no roll.

#Behaviour

  • A carry rolls forward, not back. Going from 1,199 to 1,200, the ones column steps one place rather than winding nine places backwards.
  • Columns keep their identity when the number gains or loses digits.

#Accessibility

  • Only the final formatted value is announced. The moving parts are aria-hidden.
  • Reduced motion renders the plain value, honouring both the OS setting and <MotionConfig reducedMotion="always">. Under <MotionConfig isStatic> the ticker shows the real value rather than freezing at from.

#API Reference

PropTypeDefaultDescription
valuenumberThe value to count to
variant'odometer' | 'counter' | 'flip''odometer'Which effect to run: rolling digit columns, an interpolated value, or a split-flap board
fromnumber0The value each column starts from
decimalsnumber0Decimal places to render
localestringLocale passed to Intl.NumberFormat. Defaults to the user's locale
formatIntl.NumberFormatOptionsExtra Intl.NumberFormat options, e.g. { style: 'currency', currency: 'USD' }
livebooleanfalseRender the figure instantly with no roll. Set this when the value keeps moving; a number that is mid-animation whenever you look at it cannot be read
staggernumber0.03Seconds added per column, left to right. Keep it in the 0.03–0.08 range. Ignored by the counter variant, which has no columns
durationnumber0.4Seconds for a column to settle
bouncenumber0Spring overshoot, 0–1. Off by default: no gesture precedes this motion, so an overshoot reads as the figure being briefly wrong
startOnViewbooleantrueCount when scrolled into view rather than on mount
oncebooleantrueOnly arm the reveal the first time it enters view. Later changes to value still animate; live is the prop that stops that