Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The timeline-scope property

Reference for the CSS timeline-scope property: make a named scroll or view timeline visible to elements outside the scroller's subtree, with a live example.

Named timelines have limited reach: only the element that defines the name and its descendants can use it. The timeline-scope property widens that reach. Put it on a common ancestor, list the timeline names, and everything inside that ancestor, including siblings of the scroller, can use those timelines in animation-timeline.

Use it when an element outside a scroll container, such as a progress indicator in a header or a sidebar, must follow what happens inside that container.

CSS
.layout {
  timeline-scope: --panel;
}
.panel {
  scroll-timeline: --panel y;
}
.indicator {
  animation-timeline: --panel;
}

Try it

A sibling follows the scroller

Remove the timeline-scope line and the gauge stops working, because the name --panel is then only visible inside .panel.

Syntax

CSS
timeline-scope: none | all | <dashed-ident>#
  • Initial value: none
  • Applies to: all elements
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
none No timeline names are hoisted.
<dashed-ident># One or more comma-separated names, for example --panel, --hero. Timelines with these names declared by descendants become visible to the whole subtree of this element.
all Hoist every named timeline declared by descendants. A newer keyword, so check support before relying on it.

Usage notes

  • Declare it on a shared ancestor of both the timeline's source (the scroller or view subject) and the animated element. A parent that contains both is enough.
  • The name must match exactly between timeline-scope, the scroll-timeline or view-timeline declaration and animation-timeline.
  • Duplicates. If several descendants define the same name, the hoisted name becomes ambiguous and the timeline is inactive. Use unique names for items in a list or scope them inside each item instead.
  • Not needed for descendants. If the animated element is already inside the element that defines the timeline, skip this property.
  • Pair with sensible fallbacks. The indicator should be harmless when the animation does not run, for example hidden or showing a static state.
  • Reduced motion. Gauges and progress indicators are usually fine, but large movement should respect prefers-reduced-motion.

Browser support

timeline-scope belongs to the newer scroll-driven animations specification and has more limited support than basic CSS animations. Check a compatibility table before depending on it, and treat the effect as an enhancement.