Skip to content

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

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

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.

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.ts
  • lib/cn.ts
  • styles/
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.ts
  • lib/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.

Props

PropTypeDefaultDescription
placementScrollProgressPlacement"top"Fixed to the top or bottom edge of the viewport, or "inline" to sit in the flow (for example inside a card header or a sticky bar of your own).
containerRefObject<HTMLElement | null>the pageThe scrollable element to follow.
thicknessnumber4Sets the height of the bar in px.
smoothbooleantrueEase the bar after the scroll with the scroll spring, so it glides instead of stepping. Ignored under reduced motion, where it follows the scroll exactly.
colorFromstring"var(--sheen-accent)"Colour at the start of the bar, any CSS colour.
colorTostring"var(--sheen-accent-2)"Colour at the leading end of the bar, any CSS colour.
labelstringNoneAccessible name. Leave it out (the default) when the bar only decorates a page that already has a scrollbar: the bar is then hidden from assistive technology. Set it ("Reading progress") when the position matters, and the bar becomes a progressbar whose value updates in 5 % steps.

Keyboard

KeysAction
TabNot focusable and never takes pointer events.

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

19 effects pages in all: browse them on All effects.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .