cnippet/ui
  1. motion
  2. text animations
  3. counting number

text animations

Counting Number

Smoothly animates from a start value to a target number using a spring or tween. Supports imperative replay via a ref and fires start/complete callbacks.

Installation

Usage

Anatomy

Good to know

  • It counts from from (default 0) to target once, when it mounts.
  • Set autoStart={false} and call ref.current.startAnimation() to start it yourself, for example when it scrolls into view.
  • onStart and onComplete fire at the beginning and end of the count.
  • For a number that changes over time, use AnimatedNumber or SlidingNumber.
  • When the user has turned on reduced motion, it shows target straight away; onStart and onComplete still fire.

Props

Ref API

Pass a ref to access startAnimation() imperatively:

Examples

Stats Section

Four CountingNumber components animate a social-proof grid on mount. Values use toLocaleString formatting automatically.

Large Hero Metric

A single full-width counter dominates the hero section with a large typographic treatment. A replay button calls ref.current.startAnimation() to re-run the count.

Dashboard Metrics

Three counters inside bordered cards with gradient text colours. Different duration values create a staggered feel without any extra wrapper logic.