Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Scroll Progress

Free

A reading-progress bar for the page or any scroll container.

Installation

pnpm dlx shadcn@latest add @viewport/scroll-progress

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

scroll-progress-demo.tsx
"use client";

import { useRef } from "react";
import { ScrollProgress } from "@/components/viewport/scroll-progress";

export default function ScrollProgressDemo() {
  const ref = useRef<HTMLDivElement>(null);
  return (
    <div ref={ref} tabIndex={0} className="relative h-72 w-full max-w-md overflow-y-auto rounded-2xl border border-border bg-card outline-none focus-visible:ring-2 focus-visible:ring-ring">
      <ScrollProgress container={ref} />
      <article className="space-y-4 p-6 text-sm leading-relaxed text-muted-foreground">
        <h3 className="text-base font-semibold text-foreground">Scroll this panel</h3>
        {Array.from({ length: 7 }, (_, i) => (
          <p key={i}>
            Motion should explain what changed, not decorate it. A progress bar that tracks reading position is a small promise: you
            always know how much is left.
          </p>
        ))}
      </article>
    </div>
  );
}

Props

PropTypeDefault
containerReact.RefObject<HTMLElement | null>

Track a scrollable element instead of the page.

—
classNamestring—

Accessibility

  • Decorative and aria-hidden.
  • Driven by scroll position, so it only moves when the user does.