Skip to main content
VelinStyle v0.8.0
⌂ Home
  1. Docs
  2. Components
  3. Counter

Counter

The <velin-counter> Web Component animates a number from from to to using requestAnimationFrame and an expo-out easing, then formats via Intl.NumberFormat. Designed for KPI tiles, hero stats, and pricing pages.

Basic

<velin-counter from="0" to="2540" duration="1500"></velin-counter>

Currency & locale

<velin-counter from="0" to="61840"
  format="currency" currency="EUR" locale="de-DE"
  decimals="0" duration="1200"></velin-counter>

Percent

<velin-counter from="0" to="0.94" format="percent" decimals="1"></velin-counter>

Attributes

AttributeDefaultNotes
from0Starting value
to0Target value
duration900ms
decimalsautoFixed fraction digits
formatnumbernumber / currency / percent
currencyEURISO 4217 code, used with format="currency"
localebrowserBCP-47 tag (e.g. de-DE, en-US)
prefix / suffixStrings wrapped around the formatted number
autostarttrueSet false to start manually via start()

JavaScript API

const counter = document.querySelector('velin-counter');
counter.start();   // re-runs the animation
counter.reset();   // jumps back to "from"
counter.setAttribute('to', 99000); // implicit re-animate

Accessibility & reduced motion