A number that counts up to its value, written straight to the DOM.
Installation
Usage
<script setup lang="ts">
import { CountingNumber } from '@animate-ui/vue/primitives/texts/counting-number';
</script>
<template>
<CountingNumber :number="2025" in-view />
</template>A new number springs on from where the count is instead of restarting it.
Animation
- Counts from
from-numbertonumberon a spring (stiffness: 90, damping: 50): most of the range goes by in the first second, then the last units tick in slowly (2025 lands after about 4.5s). - The ticking value is written to the DOM directly, without a Vue render per frame.
transitiontakes other spring options, or any Motion transition with atypeor anease.<AnimateUIProvider :tempo>paces the default spring.- Under reduced motion, the number shows its target right away.
- Screen readers read the target value once, never the ticking values.
API Reference
CountingNumber
| Prop | Type | Default |
|---|---|---|
number | number | - |
from-number? | number | 0 |
pad-start? | boolean | false |
decimal-separator? | string | '.' |
thousand-separator? | string | - |
decimal-places? | number | 0 |
transition? | SpringOptions | Transition | { stiffness: 90, damping: 50 } |
delay? | number | 0 |
initially-stable? | boolean | false |
in-view? | boolean | false |
in-view-margin? | string | '0px' |
in-view-once? | boolean | true |
...props? | HTMLAttributes | - |