CSS Portal

CSS scroll-timeline Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The scroll-timeline CSS property allows an animation’s progress to be driven by the scrolling of an element or the viewport, rather than by time. Instead of an animation running for a fixed duration, its progress is tied to how far a user scrolls, creating effects that feel directly connected to user interaction. This makes it especially useful for storytelling layouts, reveal-on-scroll effects, progress-based animations, and immersive UI experiences where motion responds naturally to scrolling behavior rather than running independently of it.

At its core, scroll-timeline defines a scroll-based timeline that an animation can follow. When paired with properties such as animation-timeline, it allows developers to map animation progress directly to a scroll container or the root scrolling element. As the user scrolls forward or backward, the animation advances or reverses accordingly, creating a strong visual connection between movement and user input. This approach improves perceived performance and clarity because animations only progress when the user interacts, rather than playing automatically.

Another important aspect of scroll-timeline is how it supports modern, declarative animation patterns without relying on JavaScript scroll listeners. This results in smoother animations, better performance, and more maintainable code. When combined thoughtfully with layout and visual design, scroll-driven timelines can guide attention, highlight content transitions, and enhance storytelling without overwhelming the user. In more advanced setups, scroll-timeline can also work alongside related features like view-timeline, allowing animations to respond to when elements enter or exit the viewport, further expanding creative possibilities for scroll-based motion design.

Definition

Initial value
see individual properties
Applies to
all elements
Inherited
no
Computed value
see individual properties
Animatable
no
JavaScript syntax
object.style.scrollTimeline

Syntax

scroll-timeline: [name] [axis];

Values

  • [name]This defines a custom name for your timeline, which you then reference in the animation-timeline property.
  • [axis]This defines which scroll direction should trigger the animation.

Example

<div class="container">
<div class="progress-bar"></div>

<section>
<h1>Scroll Down</h1>
<p>Watch the bar at the top of the screen.</p>
</section>
<section><h2>Keep Going...</h2></section>
<section><h2>Almost there...</h2></section>
<section><h2>The End.</h2></section>
</div>
/* 1. Define the scroll container */
.container {
  height: 100vh;
  overflow-y: scroll;
  
  /* Create a scroll timeline named "page-scroll" */
  /* 'axis' can be block (vertical) or inline (horizontal) */
  scroll-timeline-name: --page-scroll;
  scroll-timeline-axis: block;
}

/* 2. The element we want to animate */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 10px;
  background-color: #3498db;
  transform-origin: left;
  
  /* Link the animation to our scroll timeline */
  animation: grow-progress auto linear;
  animation-timeline: --page-scroll;
}

/* 3. The animation keyframes */
@keyframes grow-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* Basic styling for visibility */
section {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #ddd;
}

Browser Support

The following information will show you the current browser support for the CSS scroll-timeline property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported in some modern browsers, but not all.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 2nd January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!