Components
Count Up
A number that counts up to its value.
Signups this month
<CountUp value={12840} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/count-up.jsonimport { CountUp } from "@/components/count-up"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
The number counts up once it scrolls into view. When value changes later, it counts from where it is to the new value. Screen readers get the final value straight away, never the in-between numbers.
import { CountUp } from "@/components/count-up";
export function Stat() {
return <CountUp value={12840} className="text-4xl font-semibold" />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | The number to count to. | |
from | number | 0 | Where the first count starts. |
duration | number | 1.5 | Seconds the count takes. |
decimals | number | 0 | Decimal places shown. |
locale | string | the browser's | Locale for digit grouping, e.g. "de-DE". |
className | string | Classes for the outer <span>. |
With reduced motion, the value shows at once.