Count Up

Animated number counter with spring physics using Framer Motion

Preview
Source Code
+

Components shipped

Overview

CountUp animates a number from one value to another using spring physics from Framer Motion. It triggers when the element scrolls into view and supports counting up or down with configurable duration and formatting.

Features

  • Spring physics — natural motion with configurable damping and stiffness
  • Viewport trigger — starts counting when scrolled into view via useInView
  • Decimal support — handles fractional numbers with proper formatting
  • Custom separator — format large numbers with commas, spaces, or any character
  • Bidirectional — count up or down with the direction prop

Usage

import CountUp from '@/components/count-up'

<CountUp from={0} to={500} separator="," className="text-5xl font-bold" />

<CountUp from={100} to={0} direction="down" duration={3} />

Props

PropTypeDefaultDescription
tonumberTarget number (required)
fromnumber0Starting number
direction'up' | 'down''up'Count direction
delaynumber0Delay before counting starts (seconds)
durationnumber2Approximate animation duration (seconds)
classNamestring''CSS class for the span element
startWhenbooleantrueAdditional condition to start the animation
separatorstring''Thousands separator character
onStart() => voidCallback when counting begins
onEnd() => voidCallback when counting ends

On this page