A Vue 3 component wrapper for CountUp.js with full TypeScript support.
- ⚡️ Vue 3 Powered - Built with Vue 3 Composition API
- 🔷 TypeScript First - Complete type definitions included
- 🎯 Simple & Flexible - Easy to use with sensible defaults
- 📦 Lightweight - Small bundle size with tree-shaking support
- 🎨 Customizable - Full access to CountUp.js options
- ♿️ Accessible - Implements accessibility best practices
Version 5.x is a major rewrite with breaking changes:
- Vue 3.3+ required (Vue 2 is no longer supported)
- Migrated to TypeScript
- Uses Composition API
- Minimum Node.js version: 18
If you need Vue 2 support, please use version 4.x.
# npm
npm install vue-countup-v2 countup.js
# pnpm
pnpm add vue-countup-v2 countup.js
# yarn
yarn add vue-countup-v2 countup.js
# bun
bun add vue-countup-v2 countup.js<script setup lang="ts">
import { VueCountUp } from 'vue-countup-v2'
</script>
<template>
<VueCountUp :end-val="1000" />
</template><script setup lang="ts">
import { VueCountUp } from 'vue-countup-v2'
const options = {
duration: 2.5,
decimalPlaces: 2,
prefix: '$',
suffix: ' USD',
separator: ',',
}
</script>
<template>
<VueCountUp :end-val="9999.99" :options="options" />
</template><script setup lang="ts">
import { ref } from 'vue'
import { VueCountUp } from 'vue-countup-v2'
const count = ref(0)
const increment = () => {
count.value += 100
}
</script>
<template>
<div>
<VueCountUp :end-val="count" />
<button @click="increment">+100</button>
</div>
</template><script setup lang="ts">
import { ref } from 'vue'
import { VueCountUp } from 'vue-countup-v2'
const countUpRef = ref()
const start = () => countUpRef.value?.start()
const pause = () => countUpRef.value?.pauseResume()
const reset = () => countUpRef.value?.reset()
</script>
<template>
<div>
<VueCountUp ref="countUpRef" :end-val="5000" :delay="-1" />
<button @click="start">Start</button>
<button @click="pause">Pause/Resume</button>
<button @click="reset">Reset</button>
</div>
</template>| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
endVal |
number |
Yes | - | The target number to count to |
delay |
number |
No | 0 |
Delay in milliseconds before starting |
options |
object |
No | {} |
CountUp.js configuration options |
| Option | Type | Default | Description |
|---|---|---|---|
startVal |
number |
0 |
Number to start from |
duration |
number |
2 |
Animation duration in seconds |
decimalPlaces |
number |
0 |
Number of decimal places |
useEasing |
boolean |
true |
Enable easing animation |
useGrouping |
boolean |
true |
Use grouping (e.g., 1,000) |
separator |
string |
',' |
Grouping separator |
decimal |
string |
'.' |
Decimal separator |
prefix |
string |
'' |
Text prepended to result |
suffix |
string |
'' |
Text appended to result |
See the full options documentation for more details.
Access these methods via template ref:
start(callback?)- Start or restart the animationpauseResume()- Toggle pause/resumereset()- Reset to start valueupdate(newEndVal)- Update to a new end valueprintValue(value)- Print a value without animating
| Event | Parameters | Description |
|---|---|---|
ready |
(instance: CountUp, CountUpClass: CountUp) |
Emitted when instance is initialized |
Full TypeScript support is included:
<script setup lang="ts">
import { VueCountUp, type VueCountUpProps } from 'vue-countup-v2'
import type { CountUpOptions } from 'countup.js'
const options: CountUpOptions = {
duration: 2,
decimalPlaces: 2,
prefix: '$',
}
const props: VueCountUpProps = {
endVal: 1000,
delay: 500,
options,
}
</script>
<template>
<VueCountUp v-bind="props" />
</template><VueCountUp
:end-val="1234567.89"
:options="{
prefix: '$',
decimalPlaces: 2,
separator: ',',
}"
/>
<!-- Output: $1,234,567.89 --><VueCountUp
:end-val="85.5"
:options="{
suffix: '%',
decimalPlaces: 1,
}"
/>
<!-- Output: 85.5% --><script setup lang="ts">
import { ref } from 'vue'
const timeLeft = ref(60)
setInterval(() => {
if (timeLeft.value > 0) timeLeft.value--
}, 1000)
</script>
<template>
<VueCountUp
:end-val="timeLeft"
:options="{ suffix: 's', duration: 1 }"
/>
</template>For detailed documentation, examples, and API reference, visit:
Version 5 introduces breaking changes. See the CHANGELOG for detailed migration instructions.
Key changes:
- Vue 3.3+ required
- TypeScript rewrite
- Composition API
- New prop names (camelCase)
- New import syntax
Contributions are welcome! Please feel free to submit a Pull Request.