Skip to Content
zjkm-ui
Components

Count Up

A number that counts up to its value.

Signups this month

12,840
Props
12840
1.5s
0
<CountUp value={12840} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/count-up.json
import { 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

PropTypeDefaultDescription
valuenumberThe number to count to.
fromnumber0Where the first count starts.
durationnumber1.5Seconds the count takes.
decimalsnumber0Decimal places shown.
localestringthe browser'sLocale for digit grouping, e.g. "de-DE".
classNamestringClasses for the outer <span>.

With reduced motion, the value shows at once.

On this page