Number Counter

Animated number counter that counts from 0 to target. Tabular nums prevent layout shift, smooth ease-out-expo easing, respects reduced motion.

Component

00+0

Installation

 

Usage

Import

Add the NumberCounter import.

import { NumberCounter } from "@/components/number-counter";

Use

Pass the target value.

<NumberCounter value={9876} />;

Guidelines

  • value: target number to count up to. Animation starts from 0.
  • trigger='inView' (default): animates when scrolled into view. trigger='mount': starts immediately.
  • Use tabular-nums (built-in) and minWidth to prevent layout shift as digits change.
  • suffix and prefix for values like '35+' or '$1,000'.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
valuenumber-Target number to count up to.
classNamestring-Additional CSS classes.
durationnumber1500Animation duration in ms.
trigger"mount" | "inView""inView""mount" = start on mount. "inView" = animate when scrolled into view.
inViewThresholdnumber0.3IntersectionObserver threshold for inView trigger.
suffixstring""Text appended after the number (e.g. '+', 'K').
prefixstring""Text prepended before the number (e.g. '$').

Examples

Basic

Counts from 0 to 9876 when scrolled into view.

00+0
import { NumberCounter } from "@/components/number-counter";

<NumberCounter
  value={9876}
  className="font-bold text-2xl"
/>;

With suffix

With suffix for values like 35+.

00+0
import { NumberCounter } from "@/components/number-counter";

<NumberCounter
  value={35}
  suffix="+"
  className="font-bold text-2xl"
/>;

On mount

Starts on mount, 2 second duration.

00+0
import { NumberCounter } from "@/components/number-counter";

<NumberCounter
  value={24}
  trigger="mount"
  duration={2000}
/>;

Last updated on Mar 10

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: