Scroll Progress

A scroll-linked progress bar driven without overshoot.

scroll-progress.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/scroll-progress.json

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

3

Turn on the motion

npx @prequelui/cli@latest animate scroll-progress

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.

scroll-progress.tsx
import { useRef } from "react";
import { ScrollProgress } from "@/components/prequelui/scroll-progress";

export default function Demo() {
  const ref = useRef<HTMLDivElement>(null);
  return (
    <div className="w-[320px]">
      <ScrollProgress containerRef={ref} />
      <div ref={ref} className="h-40 overflow-y-auto">
        {/* long content */}
      </div>
    </div>
  );
}
import { ScrollProgress } from "@/components/prequelui/scroll-progress";

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

Animation

The bar follows a container or the page through a spring that is damped to zero bounce. Scroll events only write the raw ratio; the spring is what gives the bar its short, smooth catch-up.

  • Spring: 250 / 40 with bounce 0.
  • A ref target measures its own scroll range; no ref targets the page.
  • The bar scales on X from a left origin, never animating width.
  • A resize listener re-measures the range.
  • Scroll updates are passive and never block the page.
spring 250 / 40bounce 0scaleXpassive scroll

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.

ScrollProgress

PropTypeDefault
containerRefRefObject<HTMLElement>—
barClassNamestring—
transitionTransitioncomponent spring or tween
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026