scroll animations
Scroll Progress
A spring-animated progress bar that tracks scroll position — works for the full page or a scrollable container element.
Installation
Usage
Anatomy
Good to know
- It has no position or color of its own. Place it with
className, for examplefixed inset-x-0 top-0, and give it a background color. - By default it tracks the whole page. To track a scrollable element instead, pass that element's ref as
containerRef. - Change how smoothly it follows scrolling with
springOptions(Motion spring settings). - When the user has turned on reduced motion, the bar follows the scroll position directly, without the spring.
Props
Examples
Fixed Reading Progress Bar
A 1 px bar fixed to the top of the viewport, coloured with the primary theme token. Tracks window scroll.
In-Container Progress
A scrollable changelog card with a gradient progress bar along the bottom of the header. Pass a containerRef to scope tracking to the card's scroll area.
Styled Bar with Percentage Label
A rounded gradient bar with a live percentage counter rendered next to it using useTransform. The label updates in sync with the smooth spring value.