Scroll Progress Bar for React
ScrollProgress is a React effect: a thin bar that fills with page or container scroll through a scaleX transform. It is decorative by default and becomes a named progressbar only when you pass a label.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/scroll-progress.jsonA long read
Intro. Scroll this panel and watch the bar above it fill.
Setup. Scroll this panel and watch the bar above it fill.
Usage. Scroll this panel and watch the bar above it fill.
Options. Scroll this panel and watch the bar above it fill.
Accessibility. Scroll this panel and watch the bar above it fill.
Summary. Scroll this panel and watch the bar above it fill.
Just started reading.
ScrollProgress
Following a panel
container follows a scrollable element and placement="inline" keeps the bar in the flow, here above the content inside a glass card. With label the bar is exposed as a progressbar that updates in 5 % steps.
A long read
Scroll this panel and watch the bar fill.
import { useRef } from "react";
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { ScrollProgress } from "@/components/sheenui/scroll-progress/scroll-progress";
// Package build (after the first npm release, or a packed tarball): import { GlassCard, ScrollProgress } from "@sheenui/theme";
// This example also uses glass-card: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json
export function Example() {
const scroller = useRef<HTMLDivElement>(null);
return (
<GlassCard className="w-full max-w-md overflow-hidden">
<ScrollProgress placement="inline" container={scroller} label="Reading progress" />
<div ref={scroller} className="h-72 overflow-y-auto p-6">
<h2 className="text-lg font-semibold">A long read</h2>
<p className="mt-2 h-[48rem] text-sm text-sheen-fg-muted">Scroll this panel and watch the bar fill.</p>
</div>
</GlassCard>
);
}Files to copy
5 folders · 4 files · 3 packages
- From
theme/src/ components/scroll-progress/hooks/{use-media-query.ts, use-preferences.ts}motion/tokens.tslib/cn.tsstyles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/scroll-progress.jsonRegistry item: scroll-progress. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/glass-card/motion/light-follower.tslib/heading.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json- Packages
pnpm add clsx motion tailwind-merge
Fixed to the page
The default placement is the top edge of the viewport and follows the page scroll. This site shows it as a thin strip while you read; colours default to the accent tokens and can be overridden with colorFrom and colorTo.
On a real page, <ScrollProgress /> sits fixed along the top edge. It is not mounted here so it does not cover this site's own header.
import { ScrollProgress } from "@/components/sheenui/scroll-progress/scroll-progress";
// Package build (after the first npm release, or a packed tarball): import { ScrollProgress } from "@sheenui/theme";
export function Example() {
return <ScrollProgress thickness={4} />;
}Props
Keyboard
Accessibility
- Decision: decorative by default and aria-hidden, because browsers already show and announce scroll position and a role that changes on every scroll would be noise.
- Pass label only where the position carries meaning (a course, a long form): the bar becomes a progressbar with that name and a value that updates in 5 % steps, never on every pixel.
- Reduced motion: the bar still tracks the scroll exactly (a direct mapping, not an animation) but without the spring. In forced colors it uses the system highlight colour.
- The fill is a scaleX transform driven by the scroll position: no layout, no paint, no loop, so there is nothing to pause. It grows from the inline start in right-to-left pages.
When to use the scroll progress effect
- Use it on long articles, docs and guides to show how far through the reader is, fixed to the top edge.
- Pass a container ref to follow a scrollable panel, or placement="inline" to put the bar inside your own header.
- Pass label only where position matters (a course or long form); the bar then becomes a progressbar updating in 5 % steps.
- Skip the label on ordinary pages; browsers already convey scroll position and a changing role would be noise.
- Pair it with TextReveal, a sticky header and Breadcrumb.
Frequently asked questions
Related pages
19 effects pages in all: browse them on All effects.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .