Overview
Both components accept appearance and size variants. Appearances cover semantic tones (success, warning, error, info), a palette of named colors, and gradient text. Sizes scale the type from sm to lg. Animations are triggered on scroll into view, run once, and respect prefers-reduced-motion. framer-motion is an optional peer dependency.
Common use cases
- Dashboard KPIs and live metrics.
- Landing-page stat counters.
- Pricing and revenue highlights.
- Score and progress readouts.
FAQ
What is the difference between AnimatedNumber and AnimatedNumberCounter?
AnimatedNumber animates each digit into place using a motion preset (slide, scale, rotate, skew, or fade) and is best for revealing a fixed value. AnimatedNumberCounter tweens the displayed value from zero up to the target, which reads as a counting-up effect.
How do I choose the entrance animation?
Pass the type prop on AnimatedNumber: up, down, scaleUp, scaleDown, rotateX, rotateY, skewX, skewY, or fade. Tune timing with the transition and delayInSecond props.
How are the colors themed?
Every appearance maps to a --zui-animated-number-* CSS variable with a hardcoded fallback and a paired dark-mode value. Solid appearances set the text color; gradient appearances clip a linear gradient to the text.
When does the animation run?
Both components are viewport-aware: the digit entrance and the count-up only start once the element scrolls into view, and they run a single time. They also respect prefers-reduced-motion, falling back to the final value with no animation.