Overview
View timeline animations allow you to create animations that are synchronized with an element’s position in the viewport. These animations trigger when elements enter, exit, or move through the visible area of the page, creating engaging scroll-driven experiences.View timeline animations require browser support for the CSS
view-timeline property. Check Can I Use for current browser compatibility.Basic Usage
Use theview-animate-[--name] class to create a custom view timeline for your element:
--name can be any custom identifier you choose. Common examples:
--entrance- For entry animations--reveal- For reveal effects--slideShow- For slide presentations--subjectReveal- For highlighting specific content
Combining with Animations
View timelines work seamlessly with any animation class:Animation Range
Control when the animation starts and ends usinganimate-range-* classes:
Predefined Ranges
Named Range Speeds
Custom Ranges
Use arbitrary values for precise control:Real-World Example
Here’s a complete example from the library documentation, demonstrating a scroll-triggered reveal effect:This example is adapted from the MDN view-timeline documentation.
View Timeline Axis
Control the scroll direction that triggers the animation:Best Practices
Accessibility
- Respect user preferences for reduced motion:
- Ensure content is still accessible if animations don’t play
- Don’t rely solely on animations to convey important information
Tips for Great View Timelines
- Start subtle - Begin with gentle fade-ins before adding complex animations
- Match content rhythm - Use different ranges for varied pacing
- Combine with duration - Add
animate-duration-*for speed control - Test scroll speeds - Verify animations work at different scroll velocities
- Layer animations - Combine multiple elements with staggered ranges