Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Count Up Digits, animated React component

A free React count-up animation that rolls its digits like an odometer. Every column runs on its own spring, so digits far from their target spin fast and settle with a small overshoot. It starts when scrolled into view, counts again when pressed, and keeps the final number in the page text for screen readers.

  • Free
  • Motion Effects
  • Spring
  • Scroll

Like Count Up Digits? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Count Up Digits stays free.

Set it up, copy the code

Choose values for the main props and the JSX on the right updates to match.

The number to count up to.

Where the count starts.

Decimal places to show.

Text before the number, such as a currency sign.

Text after the number, such as + or %.

Group digits with commas, as in 12,480.

Start when scrolled into view, or right away.

Spring stiffness. Higher lands faster.

Your JSX

<CountUpDigits
  value={12480}
  from={0}
  decimals={0}
  prefix=""
  suffix=""
  grouping={true}
  startOn="view"
  stiffness={70}
/>

Props

PropTypeDefaultWhat it does
value12480The number to count up to.
from0Where the count starts.
decimals0Decimal places to show.
prefix""Text before the number, such as a currency sign.
suffix""Text after the number, such as + or %.
groupingtrueGroup digits with commas, as in 12,480.
startOn"view"Start when scrolled into view, or right away.
stiffness70Spring stiffness. Higher lands faster.
replayOnPresstruePressing the number counts it again.
autoplayfalseCounts again every few seconds until the visitor touches it. Never runs under reduced motion.
className—Text size and colour. Digits are sized in em, so set the font size here.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/count-up-digits
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    count-up-digits/
    count-up-digits.tsx
    index.ts
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { CountUpDigits } from "@/components/count-up-digits";
    
    export default function Page() {
      return (
        <main>
          <CountUpDigits />
        </main>
      );
    }

Like Count Up Digits? 256 more are in Pro.

Pro unlocks all 256 Pro components, every template and block, and everything we release next. Count Up Digits stays free.

Count Up Digits questions

How do I install the count up component?

Run `npx shadcn@latest add @nexus-labs/count-up-digits`. It adds the component and installs framer-motion.

How do I add a prefix, suffix or decimals?

Use `prefix`, `suffix` and `decimals`, for example `prefix="$" value={4.9} decimals={1}`. Commas are added by default, and `grouping={false}` turns them off.

How do I start the count when it scrolls into view?

That is the default (`startOn="view"`). It counts once the number is on screen. Use `startOn="mount"` to count straight away.

Is it accessible?

The rolling columns are hidden from screen readers and the final number is in the page text, so it reads as the finished value. With reduced motion on, the number appears at once.

Can visitors replay the animation?

Yes. Pressing the number counts it again, and it is a real button you can reach with the keyboard. Set `replayOnPress={false}` to make it plain text.

Guides