Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The scroll-timeline property

Reference for the CSS scroll-timeline property: give a scroll container a named progress timeline and drive animations with it, with a live example.

The scroll-timeline property turns a scroll container into a named scroll progress timeline. Progress is 0% when the container is scrolled to its start and 100% when it is scrolled to its end. Other elements can then use that name in animation-timeline.

It is a shorthand for scroll-timeline-name and scroll-timeline-axis. The anonymous scroll() function covers simple cases. A named timeline is the better choice when several animations should share one scroller, or when you want the link to be explicit.

CSS
.scroller {
  scroll-timeline: --list y;
}
.indicator {
  animation: fill linear both;
  animation-timeline: --list;
}

Try it

Progress inside a scroll box

If your browser does not support scroll-driven animations, the bar stays empty. The content is still fully usable.

Syntax

CSS
scroll-timeline: <scroll-timeline-name> <scroll-timeline-axis>?

scroll-timeline-name: none | <dashed-ident>
scroll-timeline-axis: block | inline | x | y
  • Initial value: none for the name and block for the axis
  • Applies to: scroll containers
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
none The element defines no named timeline.
<dashed-ident> A name starting with two hyphens, such as --list. Elements below the scroller can refer to it from animation-timeline.
block Track scrolling in the block axis (vertical in horizontal writing modes). This is the default.
inline Track scrolling in the inline axis.
x / y Track horizontal or vertical scrolling regardless of writing mode.

Usage notes

  • Visibility of the name. A named timeline is visible to the element itself and its descendants. To use it elsewhere, hoist it with timeline-scope on a common ancestor.
  • Only scrollable containers produce progress. If the box has no overflow, the timeline is inactive and animations do not progress.
  • Name collisions. If two ancestors define the same name, the nearest wins. Use distinctive names like --sidebar-scroll.
  • Smooth results need linear easing and a fill mode such as both. Declare animation-timeline after the animation shorthand, which resets it.
  • Anonymous alternative. For a bar that follows the nearest scroller, animation-timeline: scroll(nearest y) needs no declaration on the scroller.
  • Pair with sticky. The animated element is often position: sticky inside the scroller so it stays visible while the content moves.

Browser support

Scroll-driven animations are relatively new and are not equally supported everywhere. Check a compatibility table, and use @supports (scroll-timeline: --x) or @supports (animation-timeline: scroll()) so unsupported browsers get a static page.