CSS scroll-driven animations: a progress bar and a reveal that work
By Pulse Labs · Published · Updated · 2 min read
CSS scroll-driven animations let a page animate as a function of scroll position with no JavaScript. You write ordinary @keyframes, then set animation-timeline so the scroll bar, rather than the clock, drives them. The browser runs it, so it stays smooth even when the main thread is busy.
Two timelines cover most uses. scroll() follows how far a scroller has moved, which suits a reading-progress bar. view() follows an element as it crosses the viewport, which suits a reveal. Both examples below ran in Chrome 158 on 22 November 2026, and both are wrapped so that browsers without support, and visitors who ask for less motion, get a plain page.
Browser support
Chrome's documentation says scroll and view timelines arrived in Chrome 115 and lists Edge 115, Firefox 159 and Safari 26 on its scroll-driven animations page. WebKit's guide says the feature is available in Safari 26. Check the current tables on Can I use before relying on a specific version, because they change.
Because support is recent, always use @supports. Chrome recommends testing both properties, since a browser with only part of the feature can pass a single check.
A reading progress bar
The bar scales from 0 to 1 across the full scroll of the page. Scroll the frame to see it.
<div id="bar" aria-hidden="true"></div>
<h1>Field notes</h1>
<p>Scroll this frame. The line at the top grows with your position.</p>
<p>One. The bar is a fixed element scaled from the left edge.</p>
<p>Two. Nothing in JavaScript reads the scroll position.</p>
<p>Three. In a browser without support the bar stays hidden.</p>
<p>Four. With reduced motion switched on it also stays hidden.</p>
<p>Five. Keep going.</p>
<p>Six. Nearly there.</p>
<p>Seven. The end.</p>#bar { display: none; }
@supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
@media (prefers-reduced-motion: no-preference) {
#bar {
display: block; position: fixed; inset: 0 0 auto 0; height: 4px;
background: #c8f250; transform-origin: 0 50%; transform: scaleX(0);
animation: grow auto linear both;
animation-timeline: scroll(root block);
}
@keyframes grow { to { transform: scaleX(1); } }
}
}
p { margin: 0 0 80px; }Two details matter. animation-timeline must come after the animation shorthand, because the shorthand resets it. And the duration is auto, since the timeline, not time, sets the pace.
A reveal as an element enters the viewport
view() runs the animation while the element crosses the viewport. animation-range limits it to the part you want, here from when the element starts to enter until it is a third of the way in.
<h1>Plans</h1>
<section class="cards">
<article class="c"><h2>Starter</h2><p>For one site.</p></article>
<article class="c"><h2>Team</h2><p>For several.</p></article>
<article class="c"><h2>Studio</h2><p>For many.</p></article>
<article class="c"><h2>Agency</h2><p>For clients.</p></article>
</section>.cards { display: grid; gap: 14px; margin: 40px 0 160px; }
.c { padding: 22px; border: 1px solid #3a3160; border-radius: 14px; background: #1b1530; }
.c h2 { margin: 0 0 4px; font-size: 18px; }
.c p { margin: 0; color: #cfc8ee; }
@supports ((animation-timeline: view()) and (animation-range: 0% 100%)) {
@media (prefers-reduced-motion: no-preference) {
.c { animation: lift linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
@keyframes lift { from { opacity: 0; transform: translateY(32px); } to { opacity: 1; transform: none; } }
}
}The cards are visible by default. The animation only starts from a hidden state inside the @supports and @media blocks, so an unsupported browser shows them at once, which is the safe failure.
When CSS is the right tool, and when it is not
| You need | Use |
|---|---|
| A progress bar, a reveal, a simple parallax in current browsers | CSS scroll-driven animations |
| The same effect in every browser today | An IntersectionObserver reveal, covered in the scroll animation guide |
| A sequence with precise timing across many elements | A library such as GSAP or Motion, compared in the tool comparison |
| Effects across an existing site without writing any of this | A script that adds them. That is MotionLift, which follows scrolling and respects reduced motion for you |