Scrolling Number

A mechanical number band that scrolls and stops under a highlight.

scrolling-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/scrolling-number.json

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

3

Turn on the motion

npx @prequelui/cli@latest animate scrolling-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.

scrolling-number.tsx
import { ScrollingNumber } from "@/components/prequelui/scrolling-number";

export default function Demo() {
  return (
    <ScrollingNumber
      number={48}
      fromNumber={0}
      itemsSize={34}
      className="w-40 text-2xl"
    />
  );
}
import { ScrollingNumber } from "@/components/prequelui/scrolling-number";

export function Variant() {
  return (
    <ScrollingNumber tempo={1.2}>
      …
    </ScrollingNumber>
  );
}

Animation

The number is a mechanical band. On first view the band leaves its resting index and settles under a fixed marker with a damped spring; changing the value retargets the same motion instead of restarting it.

  • Band spring: stiffness 90, damping 30, restDelta 0.001.
  • Two neighbours above and below stay visible, faded by the mask.
  • The marker and the edge mask are decorative and hidden from assistive technology.
  • Reduced motion places the band at its final index with no travel.
band 90 / 30restDelta 0.0012 side itemsmasked edges

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.

ScrollingNumber

PropTypeDefault
numbernumber0
fromNumbernumber0
stepnumber1
itemsSizenumber30
sideItemsCountnumber2
inViewbooleanfalse
inViewOncebooleantrue
delaynumber0
onCompleted() => void—
transitionTransitioncomponent spring
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026