Count up

stable 0.5 kB
<hkCountUp>

Animates a number into view and retriggers when the target changes. The final value is in the DOM the whole time, so it is never read as a partial figure.

#directive#number

Live demo

Running in this page — interact with it.

Inputs

NameTypeDefaultDescription
countTonumber0Target value.
countDurationnumber1600Animation length in milliseconds.
countPrefix / countSuffixstring''Text either side of the number.
countDecimalsnumber0Fraction digits held during the count.

Theming

Component tokens, each falling back to a global one:

PropertyDefaultControls
--hk-countup-easecubic-bezier(0.16, 1, 0.3, 1)Easing curve.

Accessibility

  • The element is aria-live="off" and carries the final value, so screen readers announce the figure once, not every frame.
  • prefers-reduced-motion jumps straight to the target.

More in Utility