Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The view-timeline property

Reference for the CSS view-timeline property: create a named view progress timeline from an element's visibility in a scroller, with axis and inset, plus a live example.

The view-timeline property turns an element into the subject of a named view progress timeline. Progress follows how far the element has travelled through its nearest scroll container's visible area: 0% when it starts to enter and 100% when it has fully left.

The name can then be used in animation-timeline by the element's descendants (or by any element, if you share it with timeline-scope). The anonymous view() function is the short form for an element animating itself.

CSS
.card {
  view-timeline: --card block;
}
.card .badge {
  animation: spin linear both;
  animation-timeline: --card;
}

Try it

A child follows its card

The badge is upright (50%) when the card is in the middle of its journey, and shrinks at the start and end. In a browser without scroll-driven animations the badges just stay purple squares.

Syntax

CSS
view-timeline: <view-timeline-name> [ <view-timeline-axis> || <view-timeline-inset> ]?

view-timeline-name: none | <dashed-ident>
view-timeline-axis: block | inline | x | y
view-timeline-inset: [ auto | <length-percentage> ]{1,2}
  • Initial value: none for the name, block for the axis, auto for the inset
  • Applies to: all elements
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
none The element does not define a named view timeline.
<dashed-ident> The timeline's name, starting with --.
block / inline / x / y The scroll axis to track. Default block.
<length-percentage> In view-timeline-inset, shrinks the scrollport edges used for the timeline. One value applies to both edges, two values give start and end.
auto In view-timeline-inset, use the scroll container's own scroll-padding.

Usage notes

  • The subject versus the animated element. The element with view-timeline is tracked. The element with animation-timeline is animated. They can be different, which is the main advantage over the anonymous view().
  • Nearest scroller. The scroll container is the nearest ancestor that scrolls. If the page itself scrolls, that is the viewport.
  • Insets. An inset of 100px starts the timeline when the subject is 100px inside the edge. Negative values begin earlier, which is useful for pre-loading effects.
  • Use named ranges. Combine with animation-range such as entry 0% cover 40% for more control.
  • Use linear and fill modes like any scroll-driven animation.
  • Unique names. Several elements with the same name resolve to the nearest one, which is usually what you want for a repeated card.
  • Motion safety. Wrap movement-heavy effects in prefers-reduced-motion: no-preference.

Browser support

View timelines are part of the newer scroll-driven animations feature set and browser support varies. Check a compatibility table and provide a static fallback.