Number Ticker

Animated

A figure that rolls to its value the first time it lands.

Source
$npx @dinachi/cli@latest add number-ticker
12,480
variant
duration
stagger
bounce
live

Usage

import { NumberTicker } from "@/components/ui/number-ticker"

export function Total() {
  return <NumberTicker value={12480} className="text-4xl font-semibold" />
}

Examples

12,480
Digit columns roll to the value.
import { useState } from 'react';
import { NumberTicker } from '@/components/ui/number-ticker';
import { Button } from '@/components/ui/button';

export function Example() {
  const [value, setValue] = useState(12480);

  return (
    <div className="flex flex-col items-center gap-4">
      <NumberTicker value={value} className="text-4xl font-semibold" />
      <Button
        variant="outline"
        size="sm"
        onClick={() => setValue(Math.floor(2000 + Math.random() * 90000))}
      >
        Recount
      </Button>
    </div>
  );
}

Notes

Motion tier

Needs motion. add --all skips it; install with add --motion or by name.

Variants

  • odometer: rolling digit columns. The default.
  • counter: when intermediate values matter, or the format is too complex to split into columns.
  • flip: departure boards and scoreboards.

When to use it

  • A total, a result, or a stat on first paint.
  • For a value that changes more than once every few seconds, pass live.

Behaviour

  • A carry rolls forward: 1,199 to 1,200 steps the ones column one place.
  • Columns keep their identity when digits are added or removed.
  • A value that changes mid-roll redirects without restarting.

Non-Latin digits

Locales with non-Latin digits, such as ar-EG, render and announce correctly but do not roll; the value updates in place.

API

valuenumber
The value to count to.
variant"odometer" | "counter" | "flip" = "odometer"
Rolling digit columns, an interpolated value, or a split-flap board.
fromnumber = 0
The value each column starts from.
decimalsnumber = 0
Decimal places to render.
localestring
Locale for Intl.NumberFormat. Defaults to the user's locale.
formatIntl.NumberFormatOptions
Extra formatting, such as { style: "currency", currency: "USD" }.
liveboolean = false
Renders the figure instantly, with no roll. Use for values that change often.
staggernumber = 0.03
Seconds added per column, left to right; 0.03 to 0.08 works best. Ignored by counter.
durationnumber = 0.4
Seconds for a column to settle.
bouncenumber = 0
Spring overshoot, 0 to 1.
startOnViewboolean = true
Counts when scrolled into view instead of on mount.
onceboolean = true
Reveals only on first entering view. Later value changes still animate.

Accessibility

  • Only the final formatted value is announced; moving parts are aria-hidden.
  • Reduced motion, from the OS or <MotionConfig reducedMotion="always">, renders the plain value.
  • Under <MotionConfig isStatic> the ticker shows the real value.