Registry / web-framework / vue-count-to

vue-count-to

JSON →
library1.0.13jsnpmunverified

vue-count-to is a lightweight, dependency-free Vue component designed to animate the counting of numbers from a `startVal` to an `endVal` over a specified `duration`. It automatically determines whether to count up or down and supports customization of the easing function. Key features include the ability to set decimal places, separators, prefixes, and suffixes, and it offers `autoplay` functionality that triggers a re-count when `startVal` or `endVal` props change. The current stable version, as of the provided information, is `1.0.13`, indicating a mature and stable release. While a specific release cadence isn't explicitly mentioned in the documentation, its long-standing presence and continued use suggest it receives maintenance. Its primary differentiator is its simplicity and minimal footprint, making it ideal for straightforward numeric animations in Vue 2 applications, without the overhead of more complex animation libraries. It also supports Vue SSR.

npm install vue-count-to
INSTALL
IMPORT
SIG · VUE-COUNT-TO
V
vue-count-to
web-frameworkjavascriptv1.0.13
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

countTo
import countTo from 'vue-count-to';
import { countTo } from 'vue-count-to';
The component is a default export and should be imported without curly braces. For use in Vue, it must then be registered in the `components` option.
Component Registration
components: { countTo }
Registers the imported `countTo` component locally within a Vue component's options to make it available in the template.

This example demonstrates how to import and register the `countTo` component, set initial and target values, and include basic formatting options like decimals, separators, and prefixes.

<template> <div> <h1>Live Count:</h1> <countTo :startVal='startVal' :endVal='endVal' :duration='3000' :decimals="2" separator="," prefix="$"></countTo> <button @click="startCount">Start New Count</button> </div> </template> <script> import countTo from 'vue-count-to'; export default { components: { countTo }, data () { return { startVal: 0, endVal: 2025.56 } }, methods: { startCount() { // Example of manually changing values to trigger re-count if autoplay is true // Or manually start if autoplay is false via a ref (not shown in basic example) this.startVal = Math.floor(Math.random() * 100); this.endVal = Math.floor(Math.random() * 10000); } } } </script>
Debug
Known issues
gotchaWhen `autoplay` is set to `true` (which is the default), the counting animation will automatically restart every time the `startVal` or `endVal` props change. This can lead to unexpected or repetitive animations if the values are frequently updated by other reactive data sources.
fix
If this automatic re-counting behavior is not desired, set `autoplay` to `false` and manually control the animation using the component's `start()` method (accessed via a ref) when it should occur.
affects: >=1.0.0
gotchaCustom `easingFn` implementations must strictly adhere to the expected signature `(t, b, c, d)` where `t` is current time, `b` is start value, `c` is change in value, and `d` is total duration. Incorrect signatures, unexpected return values, or functions that do not correctly calculate the eased value will result in broken or non-smooth animations.
fix
Ensure your custom easing function matches the standard tweening function signature and returns the correctly interpolated value based on the input parameters. Refer to standard easing function implementations for correct patterns.
affects: >=1.0.0
Errors
Common errors & fixes
[Vue warn]: Unknown custom element: <countTo> - did you register the component correctly?
The `countTo` component was imported but not registered in the `components` option of the parent Vue component.
fix
Add `countTo` to the `components` property within your Vue component's options:
```vue
<script>
  import countTo from 'vue-count-to';
  export default {
    components: { countTo }, // <-- Add this line
    // ...
  }
</script>
```
TypeError: countTo is not a constructor (in browser console) or TypeError: Cannot read properties of undefined (reading 'start')
The `countTo` component was incorrectly imported using a named import syntax (`import { countTo } from 'vue-count-to';`) instead of a default import.
fix
Change the import statement to use a default import:
`import countTo from 'vue-count-to';`
Upgrade
Version history
1.0.13latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
vue-count-to — npm install vue-count-to · libregistry