Loading component…
Loading component…
Odometer-style numbers
To reuse this local React demo, copy all files from the Code tab into the same folder, then import NumberTicker from ./number-ticker.
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>
);
}| 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 |
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"
@import "tailwindcss"; in your main CSS file.