Animated Metric
An editorial count-up statistic — the number eases from its start value to the exact final figure when it enters the viewport, with a subtle rise-and-fade entrance and a screen-reader-friendly final value. One container-aware component scales from gallery card to fullscreen.
Installation#
pnpm dlx shadcn@latest add @davinciui/animated-metricUsage#
API Reference#
| Prop | Type | Default |
|---|---|---|
valueFinal numeric value. Rendered exactly on completion — never 2.9999999. | number | — |
prefixStatic prefix, e.g. "$" for $5m or "€" for €2.4m. | string | — |
suffixStatic suffix, e.g. "m+", "+", "%", "k+". Never animated. | string | — |
labelSmaller description under the metric, enters with a slight delay. | string | — |
startValueValue the count starts from. | number | 0 |
durationCount duration in milliseconds (1200–1800 feels like the reference). | number | 1500 |
decimalsFixed decimal places, e.g. 1 for 1.5m+ or 99.9%. | number | 0 |
delayStagger offset in milliseconds before counting starts — 0/100/200/300 across a stat row. | number | 0 |
onceAnimate once and stay. When false, leaving the viewport resets and re-entering replays. Ignored when loop is true. | boolean | true |
loopReplay indefinitely while visible, pausing loopDelay on the final value each cycle. | boolean | false |
loopDelayPause in milliseconds on the final value between loops. | number | 1500 |
thresholdFraction of the component visible before triggering (0–1). | number | 0.25 |
valueClassNameExtra classes for the metric figure. | string | — |
labelClassNameExtra classes for the label. | string | — |
Accessibility#
The root exposes role='img' with an aria-label combining the final value and label, while the animated figure is aria-hidden, so screen readers get the exact result once. No keyboard interaction is involved.
Motion#
The count eases with a cubic-bezier(0.22,1,0.36,1) curve over duration, staggered by delay; value and label fade up over 600ms and 500ms. A matchMedia check and CSS media query skip counting and transitions under reduced motion.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

