Gathering detailed insights and metrics for react-countup
Gathering detailed insights and metrics for react-countup
Gathering detailed insights and metrics for react-countup
Gathering detailed insights and metrics for react-countup
💫 A configurable React component wrapper around CountUp.js
npm install react-countup
Typescript
Module System
97.8
Supply Chain
99.5
Quality
80
Maintenance
100
Vulnerability
100
License
JavaScript (57.63%)
TypeScript (42.37%)
Total Downloads
51,061,264
Last Day
62,141
Last Week
354,275
Last Month
1,477,580
Last Year
15,623,182
MIT License
2,057 Stars
1,083 Commits
135 Forks
7 Watchers
15 Branches
26 Contributors
Updated on May 10, 2025
Minified
Minified + Gzipped
Latest Version
6.5.3
Package Id
react-countup@6.5.3
Unpacked Size
32.72 kB
Size
9.99 kB
File Count
14
Published on
Mar 22, 2024
Cumulative downloads
Total Downloads
Last Day
24.9%
62,141
Compared to previous day
Last Week
9.2%
354,275
Compared to previous week
Last Month
-4.2%
1,477,580
Compared to previous month
Last Year
37%
15,623,182
Compared to previous year
1
1
24
A configurable React component wrapper around CountUp.js.
Click here to view on CodeSandbox.
className: string
decimal: string
decimals: number
delay: ?number
duration: number
end: number
prefix: string
redraw: boolean
preserveValue: boolean
separator: string
start: number
plugin: CountUpPlugin
startOnMount: boolean
suffix: string
useEasing: boolean
useGrouping: boolean
useIndianSeparators: boolean
easingFn: (t: number, b: number, c: number, d: number) => number
formattingFn: (value: number) => string
enableScrollSpy: boolean
scrollSpyDelay: number
scrollSpyOnce: boolean
onEnd: ({ pauseResume, reset, start, update }) => void
onStart: ({ pauseResume, reset, update }) => void
onPauseResume: ({ reset, start, update }) => void
onReset: ({ pauseResume, start, update }) => void
onUpdate: ({ pauseResume, reset, start }) => void
1yarn add react-countup
1import CountUp from 'react-countup';
1<CountUp end={100} />
This will start a count up transition from 0
to 100
on render.
1<CountUp 2 start={-875.039} 3 end={160527.012} 4 duration={2.75} 5 separator=" " 6 decimals={4} 7 decimal="," 8 prefix="EUR " 9 suffix=" left" 10 onEnd={() => console.log('Ended! 👏')} 11 onStart={() => console.log('Started! 💨')} 12> 13 {({ countUpRef, start }) => ( 14 <div> 15 <span ref={countUpRef} /> 16 <button onClick={start}>Start</button> 17 </div> 18 )} 19</CountUp>
The transition won't start on initial render as it needs to be triggered manually here.
Tip: If you need to start the render prop component immediately, you can set delay={0}.
1<CountUp start={0} end={100}> 2 {({ countUpRef, start }) => ( 3 <div> 4 <span ref={countUpRef} /> 5 <button onClick={start}>Start</button> 6 </div> 7 )} 8</CountUp>
Render start value but start transition on first render:
1<CountUp start={0} end={100} delay={0}> 2 {({ countUpRef }) => ( 3 <div> 4 <span ref={countUpRef} /> 5 </div> 6 )} 7</CountUp>
Note that delay={0}
will automatically start the count up.
1<CountUp delay={2} end={100} />
1import { useCountUp } from 'react-countup'; 2 3const SimpleHook = () => { 4 useCountUp({ ref: 'counter', end: 1234567 }); 5 return <span id="counter" />; 6};
1import { useCountUp } from 'react-countup'; 2 3const CompleteHook = () => { 4 const countUpRef = React.useRef(null); 5 const { start, pauseResume, reset, update } = useCountUp({ 6 ref: countUpRef, 7 start: 0, 8 end: 1234567, 9 delay: 1000, 10 duration: 5, 11 onReset: () => console.log('Resetted!'), 12 onUpdate: () => console.log('Updated!'), 13 onPauseResume: () => console.log('Paused or resumed!'), 14 onStart: ({ pauseResume }) => console.log(pauseResume), 15 onEnd: ({ pauseResume }) => console.log(pauseResume), 16 }); 17 return ( 18 <div> 19 <div ref={countUpRef} /> 20 <button onClick={start}>Start</button> 21 <button onClick={reset}>Reset</button> 22 <button onClick={pauseResume}>Pause/Resume</button> 23 <button onClick={() => update(2000)}>Update to 2000</button> 24 </div> 25 ); 26};
className: string
CSS class name of the span element.
Note: This won't be applied when using CountUp with render props.
decimal: string
Specifies decimal character.
Default: .
decimals: number
Amount of decimals to display.
Default: 0
delay: number
Delay in seconds before starting the transition.
Default: null
Note:
delay={0}
will automatically start the count up.
duration: number
Duration in seconds.
Default: 2
end: number
Target value.
prefix: string
Static text before the transitioning value.
redraw: boolean
Forces count up transition on every component update.
Default: false
preserveValue: boolean
Save previously ended number to start every new animation from it.
Default: false
separator: string
Specifies character of thousands separator.
start: number
Initial value.
Default: 0
plugin: CountUpPlugin
Define plugin for alternate animations
startOnMount: boolean
Use for start counter on mount for hook usage.
Default: true
suffix: string
Static text after the transitioning value.
useEasing: boolean
Enables easing. Set to false
for a linear transition.
Default: true
useGrouping: boolean
Enables grouping with separator.
Default: true
useIndianSeparators: boolean
Enables grouping using indian separation, f.e. 1,00,000 vs 100,000
Default: false
easingFn: (t: number, b: number, c: number, d: number) => number
Easing function. Click here for more details.
Default: easeInExpo
formattingFn: (value: number) => string
Function to customize the formatting of the number.
To prevent component from unnecessary updates this function should be memoized with useCallback
enableScrollSpy: boolean
Enables start animation when target is in view.
scrollSpyDelay: number
Delay (ms) after target comes into view
scrollSpyOnce: boolean
Run scroll spy only once
onEnd: ({ pauseResume, reset, start, update }) => void
Callback function on transition end.
onStart: ({ pauseResume, reset, update }) => void
Callback function on transition start.
onPauseResume: ({ reset, start, update }) => void
Callback function on pause or resume.
onReset: ({ pauseResume, start, update }) => void
Callback function on reset.
onUpdate: ({ pauseResume, reset, start }) => void
Callback function on update.
countUpRef: () => void
Ref to hook the countUp instance to
pauseResume: () => void
Pauses or resumes the transition
reset: () => void
Resets to initial value
start: () => void
Starts or restarts the transition
update: (newEnd: number?) => void
Updates transition to the new end value (if given)
By default, the animation is triggered if any of the following props has changed:
duration
end
start
If redraw
is set to true
your component will start the transition on every component update.
You need to check if your counter in viewport, react-visibility-sensor can be used for this purpose.
1import React from 'react'; 2import CountUp from 'react-countup'; 3import VisibilitySensor from 'react-visibility-sensor'; 4import './styles.css'; 5 6export default function App() { 7 return ( 8 <div className="App"> 9 <div className="content" /> 10 <VisibilitySensor partialVisibility offset={{ bottom: 200 }}> 11 {({ isVisible }) => ( 12 <div style={{ height: 100 }}> 13 {isVisible ? <CountUp end={1000} /> : null} 14 </div> 15 )} 16 </VisibilitySensor> 17 </div> 18 ); 19}
Note: For latest react-countup releases there are new options
enableScrollSpy
andscrollSpyDelay
which enable scroll spy, so that as user scrolls to the target element, it begins counting animation automatically once it has scrolled into view.
1import './styles.css'; 2import CountUp, { useCountUp } from 'react-countup'; 3 4export default function App() { 5 useCountUp({ 6 ref: 'counter', 7 end: 1234567, 8 enableScrollSpy: true, 9 scrollSpyDelay: 1000, 10 }); 11 12 return ( 13 <div className="App"> 14 <div className="content" /> 15 <CountUp end={100} enableScrollSpy /> 16 <br /> 17 <span id="counter" /> 18 </div> 19 ); 20}
You can use callback properties to control accessibility:
1import React from 'react'; 2import CountUp, { useCountUp } from 'react-countup'; 3 4export default function App() { 5 useCountUp({ ref: 'counter', end: 10, duration: 2 }); 6 const [loading, setLoading] = React.useState(false); 7 8 const onStart = () => { 9 setLoading(true); 10 }; 11 12 const onEnd = () => { 13 setLoading(false); 14 }; 15 16 const containerProps = { 17 'aria-busy': loading, 18 }; 19 20 return ( 21 <> 22 <CountUp 23 end={123457} 24 duration="3" 25 onStart={onStart} 26 onEnd={onEnd} 27 containerProps={containerProps} 28 /> 29 <div id="counter" aria-busy={loading} /> 30 </> 31 ); 32}
1import { CountUp } from 'countup.js'; 2import { Odometer } from 'odometer_countup'; 3 4export default function App() { 5 useCountUp({ 6 ref: 'counter', 7 end: 1234567, 8 enableScrollSpy: true, 9 scrollSpyDelay: 1000, 10 plugin: Odometer, 11 }); 12 13 return ( 14 <div className="App"> 15 <span id="counter" /> 16 </div> 17 ); 18}
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
Found 2/14 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
42 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More