Data display
Layout
AnimatedNumber
A number whose changed digits roll to their new value, formatted for any locale. Use it for counters, prices and stats that change on screen.
Install
import { AnimatedNumber } from 'vael-ui'Playground
60
Placement, behaviour and animation
Usage
<script setup lang="ts">
import { AnimatedNumber } from 'vael-ui'
</script>
<template>
<AnimatedNumber :value="60" locale="en-US" />
</template>Motion New
AnimatedNumber: its appearance, timing for the roll, and when: 'visible'.
<AnimatedNumber
:motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>| Name | Type | Description |
|---|---|---|
initialexit | root | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
spring | { damping, response } | Times how its value moves when it changes, from the steppers, the keyboard or your code. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
It has no keyboard interaction of its own.
- The formatted value sits in visually hidden text, and the rolling digits are
aria-hidden. Screen readers read the final value, never an in-between frame. - With
{ when: 'visible' }, the digits wait at 0 on screen, but screen readers already get the value. - It has no live region, so value changes are not announced.