Odometer

Animated Number Counter for React

A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.

  • Number
  • Data
  • Motion

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
stiffness150
damping18
stagger0.03s
delay0.00s
<Odometer />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Odometer: A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.

1. Install it:
   npx shadcn@latest add @keyframeui/odometer-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/odometer-demo.json instead.)
   It adds the demo, components/odometer-demo.tsx, and the component, components/ui/odometer.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Odometer> on its own.

3. These props set its feel. Change them before you change the file:
   - stiffness (default 150): Spring stiffness of the roll. Higher is snappier.
   - damping (default 18): Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.
   - stagger (default 0.03): Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.
   - delay (default 0): Seconds to wait before rolling, after a change or, with `rollOnView`, after scrolling into view. Use it to stagger several numbers.

4. Don't change, in components/ui/odometer.tsx:
   - Each wheel's position is one continuous motion value drawn through `mod10`, so rolls, wraps and retargets are transforms and never re-render React per frame.
   - Digits roll the way the value moved, the long way round if they must, and unchanged digits stay still; the ripple starts at the rightmost changed place and each place left waits one `stagger`.
   - `rollSpring` damps long rolls so a wheel never runs more than `ODOMETER.overshoot` past its digit, and widths open and close on a critically damped spring, so the layout never wobbles.
   - Parts are keyed by place (`d0`, `g3`), so a new leading digit doesn't re-key the rest; the `sr-only` text carries the value while every slot is `aria-hidden`.
   - Reduced motion crossfades digits in place instead of rolling them, and widths jump.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/odometer.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/odometer.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/odometer

Examples

Finished sections built with Odometer. Each one installs whole, with the component included.

Pricing

Monthly and yearly plans. Prices roll down to the yearly rate and back up, the yearly total rolls down from a year of monthly bills, and Starter's $0 never moves.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Odometer: A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.
This demo, Pricing: Monthly and yearly plans. Prices roll down to the yearly rate and back up, the yearly total rolls down from a year of monthly bills, and Starter's $0 never moves.

1. Install it:
   npx shadcn@latest add @keyframeui/odometer-pricing-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/odometer-pricing-demo.json instead.)
   It adds the demo, components/odometer-pricing-demo.tsx, and the component, components/ui/odometer.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Odometer> on its own.

3. These props set its feel. Change them before you change the file:
   - stiffness (default 150): Spring stiffness of the roll. Higher is snappier.
   - damping (default 18): Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.
   - stagger (default 0.03): Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.
   - delay (default 0): Seconds to wait before rolling, after a change or, with `rollOnView`, after scrolling into view. Use it to stagger several numbers.

4. Don't change, in components/ui/odometer.tsx:
   - Each wheel's position is one continuous motion value drawn through `mod10`, so rolls, wraps and retargets are transforms and never re-render React per frame.
   - Digits roll the way the value moved, the long way round if they must, and unchanged digits stay still; the ripple starts at the rightmost changed place and each place left waits one `stagger`.
   - `rollSpring` damps long rolls so a wheel never runs more than `ODOMETER.overshoot` past its digit, and widths open and close on a critically damped spring, so the layout never wobbles.
   - Parts are keyed by place (`d0`, `g3`), so a new leading digit doesn't re-key the rest; the `sr-only` text carries the value while every slot is `aria-hidden`.
   - Reduced motion crossfades digits in place instead of rolling them, and widths jump.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/odometer.md

Dashboard KPIs

Currency with cents, a count, a percentage and milliseconds. The range switcher makes big jumps in both directions; between them the numbers drift live while the cards are on screen, and the delta chips flip color and arrow with their sign.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Odometer: A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.
This demo, Dashboard KPIs: Currency with cents, a count, a percentage and milliseconds. The range switcher makes big jumps in both directions; between them the numbers drift live while the cards are on screen, and the delta chips flip color and arrow with their sign.

1. Install it:
   npx shadcn@latest add @keyframeui/odometer-dashboard-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/odometer-dashboard-demo.json instead.)
   It adds the demo, components/odometer-dashboard-demo.tsx, and the component, components/ui/odometer.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Odometer> on its own.

3. These props set its feel. Change them before you change the file:
   - stiffness (default 150): Spring stiffness of the roll. Higher is snappier.
   - damping (default 18): Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.
   - stagger (default 0.03): Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.
   - delay (default 0): Seconds to wait before rolling, after a change or, with `rollOnView`, after scrolling into view. Use it to stagger several numbers.

4. Don't change, in components/ui/odometer.tsx:
   - Each wheel's position is one continuous motion value drawn through `mod10`, so rolls, wraps and retargets are transforms and never re-render React per frame.
   - Digits roll the way the value moved, the long way round if they must, and unchanged digits stay still; the ripple starts at the rightmost changed place and each place left waits one `stagger`.
   - `rollSpring` damps long rolls so a wheel never runs more than `ODOMETER.overshoot` past its digit, and widths open and close on a critically damped spring, so the layout never wobbles.
   - Parts are keyed by place (`d0`, `g3`), so a new leading digit doesn't re-key the rest; the `sr-only` text carries the value while every slot is `aria-hidden`.
   - Reduced motion crossfades digits in place instead of rolling them, and widths jump.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/odometer.md

Indian Grouping

A rupee fundraiser that keeps ticking up. Switch between the Indian system of lakhs and crores (₹2,45,67,890) and international thousands (₹24,567,890): the commas roll to their new places while every digit stays put.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Odometer: A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.
This demo, Indian Grouping: A rupee fundraiser that keeps ticking up. Switch between the Indian system of lakhs and crores (₹2,45,67,890) and international thousands (₹24,567,890): the commas roll to their new places while every digit stays put.

1. Install it:
   npx shadcn@latest add @keyframeui/odometer-grouping-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/odometer-grouping-demo.json instead.)
   It adds the demo, components/odometer-grouping-demo.tsx, and the component, components/ui/odometer.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Odometer> on its own.

3. These props set its feel. Change them before you change the file:
   - stiffness (default 150): Spring stiffness of the roll. Higher is snappier.
   - damping (default 18): Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.
   - stagger (default 0.03): Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.
   - delay (default 0): Seconds to wait before rolling, after a change or, with `rollOnView`, after scrolling into view. Use it to stagger several numbers.

4. Don't change, in components/ui/odometer.tsx:
   - Each wheel's position is one continuous motion value drawn through `mod10`, so rolls, wraps and retargets are transforms and never re-render React per frame.
   - Digits roll the way the value moved, the long way round if they must, and unchanged digits stay still; the ripple starts at the rightmost changed place and each place left waits one `stagger`.
   - `rollSpring` damps long rolls so a wheel never runs more than `ODOMETER.overshoot` past its digit, and widths open and close on a critically damped spring, so the layout never wobbles.
   - Parts are keyed by place (`d0`, `g3`), so a new leading digit doesn't re-key the rest; the `sr-only` text carries the value while every slot is `aria-hidden`.
   - Reduced motion crossfades digits in place instead of rolling them, and widths jump.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/odometer.md

Landing Stats

A band of headline numbers that roll up from 0 the first time they scroll into view, one after another.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Odometer: A number that rolls each digit on its own wheel, up when the value grows and down when it shrinks, and slides new digits in as the number gets longer.
This demo, Landing Stats: A band of headline numbers that roll up from 0 the first time they scroll into view, one after another.

1. Install it:
   npx shadcn@latest add @keyframeui/odometer-stats-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/odometer-stats-demo.json instead.)
   It adds the demo, components/odometer-stats-demo.tsx, and the component, components/ui/odometer.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Odometer> on its own.

3. These props set its feel. Change them before you change the file:
   - stiffness (default 150): Spring stiffness of the roll. Higher is snappier.
   - damping (default 18): Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.
   - stagger (default 0.03): Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.
   - delay (default 0): Seconds to wait before rolling, after a change or, with `rollOnView`, after scrolling into view. Use it to stagger several numbers.

4. Don't change, in components/ui/odometer.tsx:
   - Each wheel's position is one continuous motion value drawn through `mod10`, so rolls, wraps and retargets are transforms and never re-render React per frame.
   - Digits roll the way the value moved, the long way round if they must, and unchanged digits stay still; the ripple starts at the rightmost changed place and each place left waits one `stagger`.
   - `rollSpring` damps long rolls so a wheel never runs more than `ODOMETER.overshoot` past its digit, and widths open and close on a critically damped spring, so the layout never wobbles.
   - Parts are keyed by place (`d0`, `g3`), so a new leading digit doesn't re-key the rest; the `sr-only` text carries the value while every slot is `aria-hidden`.
   - Reduced motion crossfades digits in place instead of rolling them, and widths jump.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/odometer.md

Props

value Required

Typenumber

The number to show. When it changes, each digit that differs rolls to its new value, the long way round in the direction the value moved.

format

TypeIntl.NumberFormatOptions

How to format the number: currency, decimals, percent, compact notation, units. Digits roll; symbols like $, ,, % and K move with the layout and crossfade when they change.

locale

TypestringDefault"en-US"

Locale for formatting. Fixed rather than read from the browser, so the server and the browser render the same thing.

stiffness

TypenumberDefault150

Spring stiffness of the roll. Higher is snappier.

damping

TypenumberDefault18

Spring damping of the roll. Lower overshoots more. Long rolls get a little extra, so they settle a hair past their digit and never bounce.

stagger

TypenumberDefault0.03

Seconds between neighboring places starting to roll. The rightmost changing digit goes first, so a change ripples left like a carry.

delay

TypenumberDefault0

Seconds to wait before rolling, after a change or, with rollOnView, after scrolling into view. Use it to stagger several numbers.

rollOnView

TypebooleanDefaultfalse

Hold every wheel on 0 until the number first scrolls into view, then roll up to it. The layout is at its final width from the start, so nothing shifts.

grouping

Type"international" | "indian"

Where the separators go. international groups by thousands (1,234,567); indian by lakh and crore (12,34,567). Unset, it follows the locale, so en-IN is already Indian. The separator itself, and everything else, still comes from the locale and format. When it changes, the commas roll to their new places and no digit turns.

className

Typestring

Extra classes for the number. It inherits font, size, weight and color, so style it like text. Other props, like aria-live, pass through to the outer span.