$npx @dinachi/cli@latest add number-ticker
001001,00100100112,480
variantodometer
counter
flip
durationstaggerbouncelivevisitors.tsx
import { NumberTicker } from "@/components/ui/number-ticker"
export function Visitors({ value }: { value: number }) {
return <NumberTicker value={value} className="text-4xl font-semibold" />
}Usage
import { NumberTicker } from "@/components/ui/number-ticker"
export function Total() {
return <NumberTicker value={12480} className="text-4xl font-semibold" />
}Examples
001001,00100100112,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>
);
}odometer001,0010010011,284
counter01,284
flip00,0000001,284
Odometer, counter and split-flap.
import { NumberTicker } from '@/components/ui/number-ticker';
export function Example() {
return (
<div className="flex flex-col gap-3">
<NumberTicker variant="odometer" value={1284} className="text-3xl font-semibold" />
<NumberTicker variant="counter" value={1284} className="text-3xl font-semibold" />
<NumberTicker variant="flip" value={1284} className="text-3xl font-semibold" />
</div>
);
}$001001,001001001.001001$48,291.50001001.001001001,00148.291,5001001.001%48.3%
Currency, locale and percent through Intl.NumberFormat.
import { NumberTicker } from '@/components/ui/number-ticker';
export function Example() {
return (
<div className="grid gap-3 text-center">
<NumberTicker
value={48291.5}
decimals={2}
locale="en-US"
format={{ style: 'currency', currency: 'USD' }}
className="text-3xl font-semibold"
/>
<NumberTicker
value={48291.5}
decimals={1}
locale="de-DE"
className="text-3xl font-semibold"
/>
<NumberTicker
value={0.482}
decimals={1}
format={{ style: 'percent' }}
className="text-3xl font-semibold"
/>
</div>
);
}1,284
requests / minute, updates every 1.2s
A value on a timer updates instantly, with no roll.
import { useEffect, useState } from 'react';
import { NumberTicker } from '@/components/ui/number-ticker';
export function Example() {
const [requests, setRequests] = useState(1284);
useEffect(() => {
const timer = setInterval(
() => setRequests((n) => n + Math.floor(Math.random() * 40)),
1200
);
return () => clearInterval(timer);
}, []);
// Without `live` this would restart its roll every 1.2s and never settle.
return <NumberTicker value={requests} live className="text-4xl font-semibold" />;
}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.