Skip to content

Statistic ^0.1.23 ​

Bind any number — it shows the starter first, then counts quickly to the target using a rAF-driven ease-out-cubic tween. Bind a timestamp instead and it becomes a live clock (countup, countdown, or auto). Every part of the DOM is class-bindable, so you can fully restyle it.

1. Bind a number ​

Just pass value — by default it animates from 0 to the target on mount.

0
0
0
vue
<script setup lang="ts">
import { VxStatistic } from 'veloxui'
</script>

<template>
  <VxStatistic :value="112893" />
  <VxStatistic :value="48200" />
  <VxStatistic :value="7" />
</template>

2. Custom starter (from) ​

Show a starting value first, then count up (or down) to the target.

From 100
0
From 1000 down
0
Negative start
0
vue
<VxStatistic :from="100" :value="9999" />
<VxStatistic :from="1000" :value="0" />      <!-- counts down -->
<VxStatistic :from="-500" :value="2500" />

3. Animation speed ​

Control the tween with duration (ms). Set animate="false" to skip animation.

Fast (400 ms)
0
Default (1000 ms)
0
Slow (3000 ms)
0
No animation
0
vue
<VxStatistic :value="5000" :duration="400" />
<VxStatistic :value="5000" :duration="3000" />
<VxStatistic :value="5000" :animate="false" />

4. Precision and separators ​

precision sets decimal places. groupSeparator / decimalSeparator control formatting.

US
0.00
EU
0,00
Spaced
0.00
5 decimals
0.00000
vue
<VxStatistic :value="1234567.89" :precision="2" />
<VxStatistic :value="1234567.89" :precision="2"
             group-separator="." decimal-separator="," />
<VxStatistic :value="3.14159" :precision="5" />

5. Prefix / Suffix ​

Show units, currencies, or any icon around the number.

Revenue
$0.00
Conversion
0.0%
Rating
0.0 ★
Downloads
0 / month
vue
<VxStatistic :value="128459.45" prefix="$" :precision="2" />
<VxStatistic :value="68.4" suffix="%" :precision="1" />
<VxStatistic :value="4.7" :precision="1">
  <template #suffix><span style="color:#f59e0b"> ★</span></template>
</VxStatistic>

6. Trend indicator ​

trend="up" turns everything green and prepends ▲; trend="down" turns it red with ▼.

Sales
$0
Churn
0.0%
Orders
0
vue
<VxStatistic :value="23480" prefix="$" trend="up" />
<VxStatistic :value="4.2" suffix="%" :precision="1" trend="down" />

7. Countdown — bind a future timestamp ​

Pass a Date, millisecond timestamp, or ISO string. If it's in the future, the component counts down tick-by-tick (second by default). The finish event fires at zero.

Next hour
00:00:00
New year
00:00:00
Launch in
00:00:00
vue
<script setup lang="ts">
import { computed } from 'vue'
const inOneHour = computed(() => Date.now() + 60 * 60 * 1000)
</script>

<template>
  <VxStatistic title="Next hour" :timestamp="inOneHour" />
  <VxStatistic title="New year" :timestamp="new Date(2027, 0, 1)" />
</template>

8. Count-up from a past timestamp ​

If the timestamp is in the past, mode auto flips to count-up (elapsed time).

Running for
00:00:00
Since login
00:00:00
vue
<script setup lang="ts">
const launchedAt = Date.now() - 2 * 3600 * 1000
</script>

<template>
  <VxStatistic title="Running for" :timestamp="launchedAt" />
</template>

Force a specific direction with mode="countup" or mode="countdown".

vue
<VxStatistic :timestamp="someTime" mode="countup" />
<VxStatistic :timestamp="someTime" mode="countdown" />

9. Custom time format ​

Tokens: DD / D (days), HH / H (hours 0–23), mm / m (minutes 0–59), ss / s (seconds 0–59), SSS (ms). Wrap literal text in [brackets].

00d 00h 00m 00s
0 days, 00:00:00
00:00
00h 00m
vue
<VxStatistic :timestamp="target" time-format="DD[d] HH[h] mm[m] ss[s]" />
<VxStatistic :timestamp="target" time-format="mm:ss" />
<VxStatistic :timestamp="target" time-format="HH[h] mm[m]" />

10. Function-based time format ​

Pass a function for fully custom output.

Human
0s
Raw ms
0 ms
vue
<script setup lang="ts">
const human = (ms: number) => {
  const s = Math.floor(ms / 1000)
  const h = Math.floor(s / 3600)
  const m = Math.floor((s % 3600) / 60)
  const sec = s % 60
  if (h) return `${h}h ${m}m ${sec}s`
  if (m) return `${m}m ${sec}s`
  return `${sec}s`
}
</script>

<template>
  <VxStatistic :timestamp="launchedAt" :time-format="human" />
</template>

11. Fully customizable — class-bindable ​

Every visual part accepts its own class binding (rootClass, titleClass, valueClass, numberClass, prefixClass, suffixClass, trendClass). Combine with :value-style for inline CSS.

Gradient
$0
Pill
0%
Code
00:00:00
vue
<template>
  <VxStatistic :value="48240" prefix="$"
    root-class="my-stat"
    title-class="my-stat__t"
    number-class="my-stat__n"
    prefix-class="my-stat__p"
  />
</template>

<style>
.my-stat__t { color: #8b5cf6; text-transform: uppercase; letter-spacing: 0.08em; }
.my-stat__n {
  background: linear-gradient(90deg, #6366f1, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.my-stat__p { color: #a78bfa; font-weight: 700; }
</style>

12. Sizes, loading, and controls (ref API) ​

Three sizes, a skeleton loader, and an exposed start() / pause() / reset() API via template ref.

Small
0
Default
0
Large
0
Loading
Controlled
0
vue
<script setup lang="ts">
import { ref } from 'vue'
const statRef = ref()
function restart() { statRef.value.reset(); statRef.value.start() }
</script>

<template>
  <VxStatistic ref="statRef" :value="9999" :duration="2000" />
  <button @click="restart">Restart</button>
</template>

13. Live dashboard ​

When the bound value changes while animating, the component smoothly eases from the current display to the new target.

Live visitors
0
Revenue
$0
Churn
0.0%
vue
<script setup lang="ts">
import { ref, onMounted } from 'vue'
const live = ref(0)
onMounted(() => {
  setInterval(() => { live.value += Math.floor(Math.random() * 50) }, 2500)
})
</script>

<template>
  <VxStatistic title="Live visitors" :value="live" trend="up" />
</template>

Props ​

PropTypeDefaultDescription
valuenumber | string0Target value (number mode)
fromnumber | string0Starter value the counter begins from
animatebooleantrueTween from from to value with rAF
durationnumber1000Animation duration in ms
autoStartbooleantrueStart on mount (set false for manual start())
precisionnumber0Decimal places
groupSeparatorstring','Thousands separator
decimalSeparatorstring'.'Decimal separator
timestampDate | number | string | nullnullIf set, switches to time mode
mode'auto' | 'countup' | 'countdown''auto'Direction when in time mode
timeFormatstring | (ms:number)=>stringautoFormat tokens (DD HH mm ss SSS) or function
intervalnumber1000Time-mode tick rate in ms (min 16)
titlestring''Label shown above value
prefixstring''Text before value
suffixstring''Text after value
size'small' | 'default' | 'large''default'Size preset
trend'up' | 'down' | nullnullColored directional arrow
loadingbooleanfalseShow skeleton placeholder
valueStylestring | object—Inline style on the value element
rootClass / titleClass / valueClass / numberClass / prefixClass / suffixClass / trendClassstring | string[] | object''Class bindings for every DOM part

Events ​

EventPayloadWhen
tickms: numberFires on every time-mode tick
finish—Countdown reached zero
update:displaynumber | stringDisplayed value changed (animation or tick)

Exposed methods (ref) ​

MethodDescription
start()Start/resume animation or timer
pause()Stop rAF and interval
reset()Return to from (number) or zero (time) without starting

Slots ​

SlotPropsDescription
default{ display }Override the value body entirely
title—Custom title content
prefix—Custom prefix (icons, text)
suffix—Custom suffix (icons, units)