Skip to content

Countup

The Countup component smoothly animates a number from a start value to a target value. It supports custom duration, easing functions, thousand separators, decimals, prefixes and suffixes.

Basic Usage

Counts from 0 to 100 by default over 2000ms.

vue

<TCountup />

Custom Target Value

Set the target number via the modelValue prop (supports v-model for dynamic updates).

vue

<TCountup :model-value="9999" />

Duration

Control animation duration in milliseconds via the duration prop.

vue

<TCountup :model-value="500" :duration="500" />
<TCountup :model-value="500" :duration="2000" />
<TCountup :model-value="500" :duration="5000" />

Start Value & Delay

  • start — initial value (default 0)
  • delay — delay before the animation starts (ms)
vue

<TCountup :model-value="1000" :start="500" />
<TCountup :model-value="100" :delay="1000" />

Prefix & Suffix

Add text before or after the number using prefix and suffix.

vue

<TCountup :model-value="99" suffix="%" />
<TCountup :model-value="5000" prefix="$" separator="," />
<TCountup :model-value="128" prefix="User " suffix=" #" />

Decimal Places

Use decimals to set the number of decimal places and decimal to specify the decimal separator.

vue

<TCountup :model-value="1234.5678" :decimals="2" />
<TCountup :model-value="99.99" :decimals="2" separator="." decimal="," />

Grouping Separator

Control thousand-grouping via useGrouping (default true) and separator.

vue

<TCountup :model-value="1234567" separator="," />
<TCountup :model-value="1234567" separator="." />
<TCountup :model-value="1234567" separator=" " />

Easing

Three easing functions are available: linear, easeOutQuad (default), and easeOutCubic.

vue

<TCountup :model-value="1000" easing="linear" />
<TCountup :model-value="1000" easing="easeOutQuad" />
<TCountup :model-value="1000" easing="easeOutCubic" />

Visibility Trigger

With the observeVisibility prop, the animation only starts when the component enters the viewport — ideal for large numbers at the bottom of a page.

vue

<TCountup :model-value="10000" observe-visibility separator="," />

Programmatic Control

Force a full restart by incrementing a :key bound to the component, or call the exposed restart() method via template ref. The animation also auto-restarts when modelValue changes.

vue

<script setup>
import { ref } from 'vue'

const targetVal = ref(8888)
const mountKey = ref(0)
function restart() { mountKey.value++ }
</script>

<template>
  <TCountup :key="mountKey" :model-value="targetVal" separator="," />
  <button @click="targetVal = Math.floor(Math.random() * 100000)">Random Value</button>
  <button @click="restart">Restart</button>
</template>

API

Props

PropDescriptionTypeDefault
modelValueTarget valuenumber100
startInitial valuenumber0
durationAnimation duration (ms)number2000
delayDelay before animation starts (ms)number0
decimalsNumber of decimal placesnumber0
separatorThousands separator characterstring','
decimalDecimal separator characterstring'.'
prefixText prepended to the numberstring''
suffixText appended to the numberstring''
easingEasing function'linear' | 'easeOutQuad' | 'easeOutCubic''easeOutQuad'
useGroupingEnable thousand groupingbooleantrue
observeVisibilityOnly animate when the element becomes visiblebooleanfalse

Exposed Properties & Methods

Accessible via ref:

NameDescriptionType
restart()Reset and replay the animation() => void
currentValueCurrent animated value (reactive)ComputedRef<number>

Events

EventDescriptionParameters
finishedEmitted when the animation completes
update:modelValueEmitted when the target value changes via v-modelvalue: number