Interaction & Visual Craft

CSS timeline-sscope Lets One Scroll Drive Two Carousels

A new walkthrough demonstrates CSS timeline-scope syncing two carousels from one scroll gesture — vanilla CSS, no JavaScript, but the property is not yet Baseline.

  • AuthorPriya Raman
  • ChannelInteraction & Visual Craft
  • Filed
  • Read3 min
CSS timeline-sscope Lets One Scroll Drive Two Carousels
AI-generated
  • timeline-scope is not yet Baseline; author recommends decorative use only
  • sibling-count() support is nearing Baseline but not production-ready
  • Pattern links carousels via scroll-timeline: --carousel-scroll x on the primary
  • One timeline can drive multiple animations on any number of descendants

One scroll, two synchronized carousels — and not a line of JavaScript. A new walkthrough of the CSS timeline-scope property shows how a single scroll gesture on a primary carousel can drive an animation on a sibling carousel that itself cannot scroll at all.

The mechanism is narrow but real. An animation timeline — a scroll timeline or view timeline — normally serves only the element that defines it and that element's descendants. timeline-scope breaks that boundary: a named timeline becomes reachable by any element sharing an ancestor with the definer, once that ancestor carries a matching timeline-scope declaration.

Put plainly. Scroll one carousel; animate another.

What does the pattern actually build?

The demo is a typical horizontal carousel paired with a secondary one. The markup stacks them in reverse order for positioning purposes:

  • The primary carousel (.cp) gets overflow-x: auto and scroll-snap-type: x mandatory, so slides snap to center rather than skipping past.
  • The secondary carousel (.cs) gets overflow: clip, which disables scrolling and scrollbars entirely.

The animation itself is a keyframe rule, cs-scroll, that shifts the secondary slides leftward by translateX(calc(-100% * (sibling-count() - 1))) — one slide visible at a time, in step with the primary carousel's scroll progress.

That sibling-count() function, the author notes, counts the direct children of an element. Support is nearing Baseline but still rolling out; the fallback is indexing items with CSS variables directly in the markup, which the author calls more cumbersome and exactly why sibling-count() (and sibling-index()) is needed.

How does the scroll timeline get shared?

Two declarations do the linking. On the primary carousel, scroll-timeline: --carousel-scroll x registers a named timeline over the horizontal axis. On the secondary carousel's slides, animation-timeline: --carousel-scroll binds the cs-scroll animation to that timeline. Duration and delay are unnecessary here — the animation's progress tracks scroll position, not clock time.

Then the hoist. Declaring timeline-scope: --carousel-scroll on <body> lifts the timeline so both carousels, as direct children, can see it. Any common container works equally well — a .carousels wrapper would do the same job. And there is no limit of one: any number of descendant elements can consume the timeline, each with a different animation if you like.

Where would you have seen this?

The effect has familiar precedents. Racing games that roll a car's specifications past as you browse the cars. TV match broadcasts rotating player profiles and statistics in sync with a primary carousel. The pattern generalizes to browsing multiple visual focal points with one user scroll.

The author also names the canonical UI use cases: progress indicators for scrollable sections, and position markers that highlight as different parts of a page scroll into view.

Is it production-ready?

Here's the catch, and the author states it plainly: timeline-scope is not yet Baseline. The recommendation is to reserve it for decorative page elements rather than important functionality. A carousel syncing trick is eye-catching, but a user who cannot operate it loses nothing critical — that is the bar this pattern currently clears.

Two dependencies, then: timeline-scope itself and sibling-count(), both still spreading through browsers. Watch the Baseline trackers before you ship it past the decoration line. Once both land, the pattern needs no rework — only a support query check.

Source: CSS-Tricks

More from Priya Raman

Priya Raman

Show full bio

Market editor covering technology and product news in Product and interaction design, design systems at Interface Wire.

161 articles

Related articles

« Previous articleNext article »