Odometer Number

Odometer Number

An odometer for stats and prices — each digit is a rolling column that springs to its target with a mechanical overshoot, left to right.

Installation

▸ Run the following command

npx shadcn@latest add https://www.mellowui.com/r/odometer-number.json

▸ Or install manually

  1. Install dependencies: pnpm add motion
  2. Copy the source from the Code tab above.
  3. Place it at components/mellow/odometer-number.tsx
  4. Import and use.

API Reference

PropTypeDefaultDescription
valuenumber12500The number to display. Changing it re-rolls the digits.
fromnumber0Value the digits roll up from on first reveal.
trigger"scroll" | "mount""scroll"Start when scrolled into view, or immediately on mount.
localestring | falseLocale for grouping separators; false disables formatting.
decimalsnumber0Decimal places.
prefixstringRendered before the number, e.g. '$'.
suffixstringRendered after the number, e.g. '%'.
staggernumber0.06Per-column delay in seconds — left columns settle first.
stiffnessnumber110Roll spring stiffness — higher snaps harder.
dampingnumber16Roll spring damping — lower overshoots more.
soundbooleantruePlay a decelerating mechanical ratchet when the value re-rolls (not on first reveal).
hapticsbooleantrueVibrate on re-roll where supported (mobile).
confettibooleanfalseFling ticker-tape confetti when the value increases.
classNamestringAdditional CSS classes — set the font size here.