An odometer where every digit rolls independently.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/sliding-number.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/sliding-number.json
Turn on the motion
npx @prequelui/cli@latest animate sliding-numberThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { SlidingNumber } from "@/components/prequelui/sliding-number";
export default function Demo() {
return (
<SlidingNumber
number={2026}
fromNumber={1998}
thousandSeparator=","
className="text-5xl font-medium"
/>
);
}import { SlidingNumber } from "@/components/prequelui/sliding-number";
export function Variant() {
return (
<SlidingNumber tempo={1.2}>
…
</SlidingNumber>
);
}Animation
Each decimal place is a wheel of ten glyphs. When the value changes, every wheel springs to the nearest occurrence of its target digit, so 9 can pass through 0 and 1 instead of snapping.
- Wheel spring: stiffness 200, damping 20, mass 0.4.
- The count itself uses the number spring 90 / 50 before it feeds the wheels.
- Wheel width is fixed at one character with tabular numerals to prevent reflow.
- Reduced motion jumps each wheel directly to its digit.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
SlidingNumber
| Prop | Type | Default |
|---|---|---|
| number | number | 0 |
| fromNumber | number | undefined | — |
| inView | boolean | false |
| inViewOnce | boolean | true |
| delay | number | 0 |
| decimalPlaces | number | 0 |
| decimalSeparator | string | "." |
| thousandSeparator | string | undefined | — |
| padStart | boolean | false |
| onNumberChange | (value: number) => void | — |
| onCompleted | () => void | — |
| transition | Transition | component spring |
| className | string | — |