Skip to Content

CountUp

Spring-animated number counter. By default, the animation triggers automatically when the element scrolls into view via IntersectionObserver.

Props

PropTypeDefaultDescription
fromnumber0Starting value
tonumber100Target value
durationnumber2000Animation duration in milliseconds
decimalsnumber0Number of decimal places
prefixstring''Text rendered before the number
suffixstring''Text rendered after the number
autoStartbooleantrueTrigger on scroll into view. When false, only starts via ref.start().
formatter(value: number) => stringCustom number formatter
classNamestringContainer className
styleCSSPropertiesContainer style

Ref Handle

MethodDescription
start()Start the animation from from to to
reset()Reset to the from value without animating

Example

<CountUp from={0} to={1573} prefix="$" duration={2000} />
const countRef = useRef<CountUpHandle>(null) <CountUp ref={countRef} from={0} to={99.9} decimals={1} suffix="%" autoStart={false} /> <button onClick={() => countRef.current?.start()}>Animate</button>
Last updated on