Scroll Progress
MotionReact scroll progress indicator with a thin top bar and a circular percent ring, spring smoothed, tracking the window or any scroll container you pass.
Installation
npx shadcn@latest add @minidev/scroll-progress
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/scroll-progress.json
Usage
import { ScrollProgress } from "@/components/ui/scroll-progress"
export function Example() {
return (
<ScrollProgress />
)
}
API reference
| Prop | Type | Default |
|---|---|---|
| variantWhich indicators to show. | "bar""circle""both" | "both" |
| containerA scrollable element to track instead of the window. The indicators render where you put them, inside a `relative` wrapper. | React.RefObject<HTMLElement | null> | - |
| fixedPin the indicators to the viewport and track the page (or `container`). Nothing else renders. | boolean | false |
| heightBar thickness in pixels. | number | 3 |
| sizeRing diameter in pixels. | number | 40 |
| childrenWithout `fixed` or `container`, the component scrolls this content in its own panel. | React.ReactNode | - |
| titlePanel header title. | React.ReactNode | "What is new in Lumen 3.0" |
| subtitlePanel header line under the title. | React.ReactNode | "Release notes · 4 min read" |
| className | string | - |
When to use
Use it on long articles, docs and changelogs. Reach for ScrollProgressRail for a sticky rail with section labels, and the free Progress for task progress that is not tied to scrolling.
Accessibility
- The ring is a
role="progressbar"named "Reading progress" witharia-valuenowfrom 0 to 100. When only the bar is shown, the bar carries that role instead; otherwise it isaria-hidden. - The built-in panel's scroller has
tabIndex={0}, so keyboard users can scroll it. It is named by the headertitlethrougharia-labelledby.
Frequently asked questions
How do I show reading progress for the whole page?
Render <ScrollProgress fixed variant="bar" /> once. It pins a bar to the top of the viewport (and, with variant="both", a ring in the bottom-right) and tracks the window scroll. Nothing else renders.
How do I track a scrollable div instead of the page?
Pass its ref as container and place ScrollProgress inside a relative wrapper around it; the indicators are positioned absolute over that wrapper. Without fixed or container, it renders its own scrolling panel around children, with title and subtitle in a header.
Why does the bar lag a little behind the scroll?
It follows the scroll through a spring (stiffness 400, damping 40) to give it weight. Under reduced motion it tracks the scroll position exactly.
Dependencies
npm
Built from
Examples
Bar only
variant="bar" drops the ring; height is the bar thickness and children are the content the panel scrolls.
Ring only
variant="circle" keeps just the ring in the header; size is its diameter and the percent text scales with it.
Tracking your own scroller
Pass a ref to any scrollable element as container; the indicators render inside a relative wrapper of your own.