Sliding Number

An odometer where every digit rolls independently.

sliding-number.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/sliding-number.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/sliding-number.json

3

Turn on the motion

npx @prequelui/cli@latest animate sliding-number

The 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.

sliding-number.tsx
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.
wheel 200 / 20 / 0.4count 90 / 501ch wheelsnearest 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

PropTypeDefault
numbernumber0
fromNumbernumber | undefined—
inViewbooleanfalse
inViewOncebooleantrue
delaynumber0
decimalPlacesnumber0
decimalSeparatorstring"."
thousandSeparatorstring | undefined—
padStartbooleanfalse
onNumberChange(value: number) => void—
onCompleted() => void—
transitionTransitioncomponent spring
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026