Number Ticker
Odometer-style numbers – every digit rolls to its new value and counts in from zero when it scrolls into view.
Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/number-ticker.json · Import from @/components/ui/number-ticker
When to use
- KPIs, prices and counters that change while the user is looking, like dashboards or live stats
- Headline numbers on a landing page that should count in when they scroll into view
When not to use
- Dense tables with many numbers – rolling digits everywhere becomes noise
- Values that change many times per second; the roll never settles
Usage
import { NumberTicker } from "@/components/ui/number-ticker";
export function RevenueKpi({ revenue }: { revenue: number }) {
return (
<p className="text-4xl font-semibold">
<NumberTicker value={revenue} format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }} />
</p>
);
}Props
| Name | Type | Default | Description |
|---|---|---|---|
value | number | The number to show – change it and the digits roll to the new value | |
format | Intl.NumberFormatOptions | Formatting, e.g. currency, percent, compact notation or fraction digits | |
locale | string | browser locale | Locale passed to Intl.NumberFormat, e.g. "en-US" or "de-DE" |
duration | number | 900 | Length of a roll in milliseconds |
delay | number | 0 | Wait before the first count-in, in milliseconds |
className | string | Extra class on the wrapper – font size, weight and color are inherited |
Accessibility
- The formatted value is in a visually hidden text inside an aria-live="polite" region, so screen readers hear the final number once
- The rolling digit columns are aria-hidden
Responsive
- Inherits font size and weight from its parent and uses tabular numbers, so the width stays steady while rolling
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
Guides
- How to show AI agent costs and token usage – UI patterns for showing what AI agents cost – per run, per step and per agent – plus token usage, context limits and budgets.