Gathering detailed insights and metrics for use-count-up
Gathering detailed insights and metrics for use-count-up
Gathering detailed insights and metrics for use-count-up
Gathering detailed insights and metrics for use-count-up
react-use-count-up
A React hook with Typescript typings for animating a number counting up
count-up-down
This is the base repository that I use to create a simple static page for counting up or down.
@hardiknaik/react-animate-number
react library for animate number
react-native-animated-circular-counter
A react native component of animated circular progress-bar that can use for counting up/down with animation of filling/ un-filling circle.
React/React Native component and hook to animate counting up or down to a number
npm install use-count-up
Typescript
Module System
Node Version
NPM Version
TypeScript (91.05%)
JavaScript (5.96%)
HTML (3%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
433 Stars
253 Commits
15 Forks
2 Watchers
1 Branches
2 Contributors
Updated on May 26, 2025
Latest Version
3.0.1
Package Id
use-count-up@3.0.1
Size
8.70 kB
NPM Version
6.14.4
Node Version
12.18.0
Published on
Sep 05, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
:trophy: Lighter implementation and smaller bundle size in comparison with similar feature solutions
:flags: Declarative API (no more imperative calls to start()
and update()
)
:iphone: React Native support for iOS and Android
:deciduous_tree: Tree-shakable
:file_cabinet: Server-side rendering (SSR) compatibility
yarn add use-count-up
Check the React demo on CodeSandbox and React Native demo on Expo Snack to get started.
1import { CountUp } from 'use-count-up' 2 3const MyComponent = () => <CountUp isCounting end={1320} duration={3.2} />
The CountUp
component should be wrapped in a Text
component when used in a React Native project like so:
1import { Text } from 'react-native' 2import { CountUp } from 'use-count-up' 3 4const MyComponent = () => ( 5 <Text> 6 <CountUp isCounting end={1320} duration={3.2} /> 7 </Text> 8)
The hook accepts the same properties as the component. The usage for React and React Native is the same.
1import { useCountUp } from 'use-count-up' 2 3const MyComponent = () => { 4 const { value } = useCountUp({ 5 isCounting: true, 6 end: 1320, 7 duration: 3.2, 8 }) 9 10 return value 11}
The component and the hook accept the same props. They are fully interchangeable.
Prop Name | Type | Default | Description |
---|---|---|---|
isCounting | boolean | false | Play and pause counting animation |
start | number | 0 | Initial value |
end | number | - | Target value |
duration | number | - | Animation duration in seconds. Defaults to 2 seconds if end is set |
decimalPlaces | number | - | Number of decimal places after the decimal separator. Defaults to the max decimal places count from start and end props |
decimalSeparator | string | - | Decimal separator character |
thousandsSeparator | string | - | Thousands separator character |
easing | string | function | easeOutCubic | Type: easeOutCubic | easeInCubic | linear | easing func Easing function to control the animation progress |
formatter | function | - | Type: (value: number) => number | string | node A function that formats the output value. It has the highest priority so all other formatting options are ignored |
updateInterval | number | 0 | Update interval in seconds. Determines how often the animated value will change. When set to 0 the value will update on each key frame |
children | function | - | Type: ({ value: number, reset: () => void }) => number | string | node CountUp component - children prop |
onComplete | function | - | Type: () => void | {shouldRepeat: boolean, delay: number} On complete handler. Repeat animation by returning an object with shouldRepeat equals true and delay in seconds. |
onUpdate | function | - | Type: (currentValue: number | string | node) => void On value update event handler |
The hook returns the current count up value and reset method to reset the animation.
1import { useCountUp } from 'use-count-up' 2 3const { value, reset } = useCountUp({ isCounting: true })
The component's children render function will receive as props the current count up value and reset method to reset the animation.
1import { CountUp } from 'use-count-up' 2 3const MyComponent = () => ( 4 <CountUp isCounting>{({ value, reset }) => value}</CountUp> 5)
toLocaleString
with formatter
Number formatting varies per language group. For example, the number 3842.45
in German will be formatted as 3.842,45
whereas in British English it will be 3,842.45
(spot the different decimal and thousands separators). Number.toLocaleString()
is a built-in JS method that returns a string with a language-sensitive representation of the number. The basic implementation of the method will detect the default locale that is set up on the user's computer and will format the number accordingly. The browser support for toLocaleString
is incredibly good.
If you expect variance in the geographical/country distribution of your users, then this is a must. The simplest way to use toLocaleString
with the Count up component or hook is to use the formatter
prop, like so:
1import { CountUp } from 'use-count-up' 2 3const MyComponent = () => ( 4 <CountUp 5 isCounting 6 end={1320} 7 formatter={(value) => value.toLocaleString()} 8 /> 9)
toLocaleString
method accepts an object with two parameters, locale
and options
, which allows further customization of the number value. Setting up the first parameter, locale
, allows the use of a specific locale and fallback option. The second parameter, options
, will let you format the value in a custom way. For example, you may choose to add a min and max number of decimal places, or set currency. Keep in mind though that the locale
and options
arguments are not supported in all browsers.
Pass a key prop to CountUp component and change it when the animation should repeat. It can be also used when a change of start
or end
value should start the animation over.
1import { CountUp } from 'use-count-up' 2 3const MyComponent = ({ end }) => <CountUp isCounting end={end} key={end} />
Return from the onComplete
handler an object with key shouldRepeat: true
. Optionally the delay
before repeating can be set. In the example below the animation will be repeated in 2 seconds
1import { CountUp } from 'use-count-up' 2 3const onComplete = () => { 4 // do your stuff here 5 return { shouldRepeat: true, delay: 2 } 6} 7 8const MyComponent = () => ( 9 <CountUp isCounting end={4378.2} onComplete={onComplete} /> 10)
Don't provide end
and duration
props. start
prop can be set to any value
1import { CountUp } from 'use-count-up' 2 3const MyComponent = () => <CountUp isCounting start={1024.4} />
Set the easing
to "linear" and duration
to the seconds it should count up/down. The updateInterval
can be set to 1, so it updates once every second. Here is an example of a 10-second count-down:
1import { CountUp } from 'use-count-up' 2 3const MyComponent = () => ( 4 <CountUp 5 isCounting 6 start={10} 7 end={0} 8 duration={10} 9 easing="linear" 10 updateInterval={1} 11 onUpdate={(currentValue) => { 12 // it will fire once every second 13 }} 14 /> 15)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 0/7 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
Score
Last Scanned on 2025-07-07
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