A number whose changed digits roll like an odometer to the new value. Only the digits that change turn, up or down through the digits between, and a carry travels from the right one place at a time, so a live metric reads as a figure that ticks, not text that swaps.
On this page
- Live run counts
- Spend totals
- Success rate
- Token counters
Examples
Formats
Live KPI card
Installation
npx knowns-ui@latest add animated-numberPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Animated number from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/animated-number
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add animated-number
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/animated-number.tsx
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/animated-number, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "animated-number" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- valuerequired
number- The number to show. A change rolls the digits that differ.
- format
Intl.NumberFormatOptions|(n) => string- Default
grouped integer - Currency, percent, decimals, compact or signDisplay through Intl, or your own formatter. Only ASCII digits roll; separators, signs and symbols stay put.
- locale
string- Default
the runtime locale - Passed to Intl.NumberFormat.
- prefix / suffix
string- Text before or after the number, not animated.
- Direction
-- Digits roll up when the value rose and down when it fell. A new leading digit appears without a roll.
- Motion
280 ms ease-out- Transform only, and only when the value changes: nothing on first render or on an identical value. With reduced motion the new digits just appear.
- a11y
text- Screen readers get the final text, never the roll.
| Prop | Type | Default | Description |
|---|---|---|---|
| valuerequired | number | required | The number to show. A change rolls the digits that differ. |
| format | Intl.NumberFormatOptions | (n) => string | grouped integer | Currency, percent, decimals, compact or signDisplay through Intl, or your own formatter. Only ASCII digits roll; separators, signs and symbols stay put. |
| locale | string | the runtime locale | Passed to Intl.NumberFormat. |
| prefix / suffix | string | - | Text before or after the number, not animated. |
| Direction | - | - | Digits roll up when the value rose and down when it fell. A new leading digit appears without a roll. |
| Motion | 280 ms ease-out | - | Transform only, and only when the value changes: nothing on first render or on an identical value. With reduced motion the new digits just appear. |
| a11y | text | - | Screen readers get the final text, never the roll. |
What it handles
- 01Rolls only the digits that changed, upward when the value rose and downward when it fell, while separators and signs stay put.
- 02Formats with `Intl.NumberFormat` options for currency, percent and decimals, or with a function you pass as `format`, in the `locale` you choose.
- 03Adds `prefix` and `suffix` text such as "$" or " runs" that is shown next to the number and never rolls.
- 04Keys each digit by its place from the right, so a new leading digit appears without reshuffling the others.
- 05Uses tabular figures so a rolling digit keeps the width of the resting one and the line does not shift.
- 06Hands screen readers the final text in a hidden span and hides the rolling digits from them.
States
- First render
- Nothing. The number paints as it is
- none
- Value rises
- The changed digits roll upward
- 280ms, ease out
- Value falls
- The changed digits roll downward
- 280ms, ease out
- Same value
- Nothing plays
- none
- Reduced motion
- The new digits appear at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. The number paints as it is | none |
| Value rises | The changed digits roll upward | 280ms, ease out |
| Value falls | The changed digits roll downward | 280ms, ease out |
| Same value | Nothing plays | none |
| Reduced motion | The new digits appear at once | 0ms |
Works with
When to use
When to use
- A live metric that updates in place: runs, cost, a rate, where the eye should catch the change without the figure jumping.
When not to use
- A cost or token count that counts up from a start value as text: use Number Ticker.
- A trend of the number over time: use Chart.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Animated Number to my app and wire it to my own data.
- I need a live metric that updates in place: runs, cost, a rate, where the eye should catch the change without the figure jumping. Set that up with the Knowns UI Animated Number.
- Which Animated Number props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "animated-number" }) and search_docs({ query: "animated number" }).