Skip to content

Animated Number

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
Used for
  • Live run counts
  • Spend totals
  • Success rate
  • Token counters

Examples

Formats

Live KPI card

Installation

npx knowns-ui@latest add animated-number
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

valuerequired
number
The number to show. A change rolls the digits that differ.
format
Intl.NumberFormatOptions | (n) => string
Defaultgrouped 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
Defaultthe 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

  1. 01Rolls only the digits that changed, upward when the value rose and downward when it fell, while separators and signs stay put.
  2. 02Formats with `Intl.NumberFormat` options for currency, percent and decimals, or with a function you pass as `format`, in the `locale` you choose.
  3. 03Adds `prefix` and `suffix` text such as "$" or " runs" that is shown next to the number and never rolls.
  4. 04Keys each digit by its place from the right, so a new leading digit appears without reshuffling the others.
  5. 05Uses tabular figures so a rolling digit keeps the width of the resting one and the line does not shift.
  6. 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

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" }).

Need help?

Stuck on Animated Number, or found something off? We read every message.