Shadcn Animated Number
A number that counts up when it scrolls into view, then counts to each new value.
About Shadcn Animated Number
What it is. AnimatedNumber shows one figure. It counts up from zero when it first scrolls into view.
How it works. When value changes, it counts from the figure on screen to the new one, so a total can count down after a payment. format turns the running number into text, such as a currency string.
When to use it. Use it for totals, balances and statistics that change. For a stat card with a label, use Counter.
For AI agents
Hand your agent this brief or the Markdown page, not a screenshot.
When to use
- A total, balance or statistic that should count up and follow changes
- A figure next to a list that changes, such as Animated List
When not to use
- A stat card with a label, steppers or a countdown: use Counter
Agent notes
- Named export
AnimatedNumberfrom@/components/custom/blocks/AnimatedNumberBlock. It renders aspan; style it withclassName. formatruns every frame, so keep it cheap. UseIntl.NumberFormatcreated once, outside the component.- Screen readers get the final value, not the count.
- Honours
prefers-reduced-motion: the figure shows without counting.
- Install
npx shadcn@latest add https://avaraui.com/r/animated-number.json- Registry name
@avara-ui/animated-number, through the shadcn MCP server- Index
- llms.txt lists every page, or add the agent skill once
Props Reference
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | Required | The number to show. It counts up in view, then to each new value. |
format | (n: number) => string | toLocaleString | Turns the running number into text, such as a currency string. |
duration | number | 0.9 | Seconds each count takes. |
...props | HTMLAttributes<HTMLSpanElement> | undefined | Passed to the span, including className. |
Works with other components
- Animated List for the rows a total adds up.
- Counter for labelled stat cards, steppers and countdowns.
How do I format the number as money?
Pass format, for example (n) => n.toLocaleString("en-US", { style: "currency", currency: "USD" }). The figure is formatted on every frame of the count.
Does AnimatedNumber count from zero every time?
Only the first time, when it scrolls into view. After that it counts from the figure on screen to each new value.
How does AnimatedNumber handle reduced motion?
When the visitor prefers reduced motion, the figure appears at its value without counting.