Understanding ::view-transition-old
The ::view-transition-old pseudo-element represents a static snapshot of the old view state before a view transition occurs. It's a foundational component of the View Transitions API, enabling smooth, native-like animated transitions between different states of a web or mobile application.
The ::view-transition-old is one of several pseudo-elements introduced by the CSS View Transitions Module Level 1 specification. It captures and represents the visual state of an element or the entire document before the transition animation begins. When you initiate a view transition using document.startViewTransition(), the browser creates a snapshot of the current view state, which becomes accessible through this pseudo-element. This snapshot is captured before DOM changes take effect and exists within the view transitions overlay layer during the animation.
How It Works
Key characteristics of the ::view-transition-old pseudo-element:
- Represents the old view state as a static snapshot
- Created when a view transition is initiated
- Exists within the view transitions overlay layer
- Captured before DOM changes take effect
- Animated during the transition period
For cross-platform mobile development, understanding this pseudo-element is essential for creating app-like experiences in PWAs and web-based mobile interfaces. The ability to capture and animate the old view state smoothly bridges the gap between traditional websites and native mobile applications.
Static Snapshot Capture
Captures the current DOM state as a frozen image before transitions, enabling smooth visual continuity between page states.
Animation Target
Serves as the source element for smooth transition animations, working in tandem with the new view state.
CSS Styling
Fully customizable through standard CSS properties like transform, opacity, and animation.
Element Targeting
Can target specific elements with view-transition-name for granular control over individual component transitions.
Working with ::view-transition-new
The ::view-transition-old works in conjunction with ::view-transition-new, which represents the new view state after the transition. These two pseudo-elements form the core of the view transition animation system. The old snapshot is captured, the DOM updates, the new snapshot is captured, and then both pseudo-elements are animated to create a smooth visual transition.
The Transition Lifecycle
- Old view is captured and becomes
::view-transition-old - DOM updates occur
- New view is captured and becomes
::view-transition-new - Both pseudo-elements are animated simultaneously
- Default animation creates a smooth cross-fade effect
CSS Pseudo-Elements Hierarchy
::view-transition
└── ::view-transition-group(name)
└── ::view-transition-image-pair(name)
├── ::view-transition-old(name)
└── ::view-transition-new(name)
Both pseudo-elements exist simultaneously during the animation, allowing you to style and animate each independently. The default animation creates a cross-fade effect, but you can customize this with your own CSS animations to create unique transition experiences that match your mobile application's design language.
1/* Target the old view with a specific name */2::view-transition-old(root) {3 animation: custom-slide 0.4s ease-out;4}5 6@keyframes custom-slide {7 from {8 transform: translateX(0);9 opacity: 1;10 }11 to {12 transform: translateX(-100%);13 opacity: 0;14 }15}16 17/* Element-specific transitions */18::view-transition-old(card-image) {19 animation: scale-down 0.3s ease-in forwards;20}CSS Properties and Styling
Available CSS Properties
The ::view-transition-old pseudo-element supports various CSS properties that control its visual presentation and animation behavior. These properties enable fine-grained control over how the old view snapshot appears and transitions during the animation.
| Property | Purpose |
|---|---|
object-fit | Controls how the snapshot fits within its container |
transform | Applies transformations to the old snapshot |
opacity | Controls transparency during transition |
animation | Defines custom animation sequences |
width/height | Controls dimensions of the snapshot |
inset | Positions the snapshot within the viewport |
Using view-transition-name
The view-transition-name CSS property is crucial for targeting specific elements during view transitions. By assigning unique transition names to elements, developers can create granular animations that focus on particular UI components rather than the entire page. This is particularly valuable for mobile interfaces where screen real estate is limited and focused animations improve the user experience.
.card {
view-transition-name: card-transition;
}
::view-transition-old(card-transition) {
/* Custom animation for this specific element */
animation: slide-out 0.3s ease-out forwards;
}
By targeting specific elements, you can create polished transitions for cards, images, lists, and other components in your mobile application interfaces.
Browser Support Status (2025)
111+
Chrome Version
144+
Firefox Version
18+
Safari Version
100%
Modern Browser Support
Browser Compatibility
As of 2025, the View Transitions API has achieved broad support across major browsers, making it a viable option for production use in cross-platform mobile applications.
| Browser | Version | Status |
|---|---|---|
| Chrome | 111+ | Full Support |
| Edge | 111+ | Full Support |
| Firefox | 144+ | Full Support |
| Safari | 18+ | Full Support |
Progressive Enhancement
For cross-platform mobile development, implementing view transitions with progressive enhancement ensures that users on older browsers still receive a functional experience. This approach is essential for reaching the widest possible audience across different devices and browser versions.
// Feature detection
if (document.startViewTransition) {
// Use view transitions for smooth navigation
document.startViewTransition(() => {
// Your navigation logic here
});
} else {
// Fallback to standard navigation
window.location.href = newUrl;
}
This pattern ensures your Progressive Web Apps work seamlessly across all browsers while providing enhanced experiences where supported.
Implementation in Cross-Platform Mobile Development
Progressive Web Apps (PWAs)
View transitions are particularly valuable for PWAs, creating native-app-like navigation experiences. The ::view-transition-old pseudo-element plays a central role in these animations, enabling smooth transitions that rival native mobile applications.
Key benefits for PWA development:
- SPA-style navigation in PWAs without full page reloads
- Smooth page transitions that maintain app-like feel on mobile browsers
- Integration with service workers for offline-capable transitions
- Reduced perceived loading time through visual continuity
React Native and Web Views
While React Native uses native components, web-based views and embedded web content can leverage view transitions for consistent cross-platform experiences. WebView implementations in React Native can utilize these transitions to create seamless navigation within hybrid app architectures.
This approach is particularly valuable when building:
- Hybrid applications combining native and web views
- Embedded content sections within native interfaces
- Cross-platform applications targeting multiple mobile platforms
- Progressive web apps that integrate with native shell applications
By mastering view transitions, developers can deliver polished, professional user interfaces that compete with native applications across iOS and Android platforms.
Common Patterns and Examples
Page Transition Patterns
These patterns work well for creating engaging navigation experiences in mobile web applications:
/* Slide out old page to the left */
::view-transition-old(root) {
animation: slide-out-left 0.3s ease-in-out forwards;
}
@keyframes slide-out-left {
from { transform: translateX(0); }
to { transform: translateX(-30px); opacity: 0.8; }
}
/* Fade out old page */
::view-transition-old(root) {
animation: fade-out 0.25s ease-in-out forwards;
}
@keyframes fade-out {
from { opacity: 1; }
to { opacity: 0; }
}
/* Slide and fade combined */
::view-transition-old(root) {
animation: slide-fade-out 0.3s ease-out forwards;
}
@keyframes slide-fade-out {
from {
transform: translateX(0) scale(1);
opacity: 1;
}
to {
transform: translateX(-50px) scale(0.95);
opacity: 0;
}
}
List and Grid Transitions
For animating list items during reordering, filtering, or pagination:
::view-transition-old(list-item) {
animation: list-exit 0.3s ease-out forwards;
}
@keyframes list-exit {
from {
transform: scale(1);
opacity: 1;
}
to {
transform: scale(0.9);
opacity: 0;
}
}
These patterns are particularly effective for mobile app interfaces where smooth, intuitive navigation enhances the user experience.
Performance Considerations
Rendering Performance
The ::view-transition-old pseudo-element captures a snapshot of the current view, which has performance implications that developers should understand and optimize for, especially on mobile devices with limited resources.
Key performance factors:
- Snapshot creation overhead: Minimal but measurable on low-end devices
- GPU acceleration: Most transition animations are GPU-accelerated for smooth playback
- Memory usage: Snapshot requires additional memory for the duration of the transition
- Mobile optimization: Critical for smooth performance on phones and tablets
Optimization Strategies
- Limit transition scope: Target specific elements rather than entire pages when possible
- Use
will-changeappropriately: Hint to browsers which elements will animate - Avoid expensive CSS properties: Stay away from box-shadow, blur, and layout-triggering properties during animation
- Test on target devices: Emulators don't fully represent real-world mobile performance
- Consider reduced motion: Respect user preferences for reduced animation
Performance Checklist
- Use
transformandopacityfor best animation performance - Avoid layout-triggering properties during animation
- Test on representative device range (including lower-end devices)
- Monitor frame rates during transitions using browser DevTools
- Consider
prefers-reduced-motionmedia query for accessibility
For optimal web development best practices, always profile your transitions on actual mobile devices and implement fallbacks for users who prefer reduced motion.
Frequently Asked Questions
What is the difference between ::view-transition-old and ::view-transition-new?
::view-transition-old captures the state before DOM changes, while ::view-transition-new captures the state after changes. Both pseudo-elements exist simultaneously during the transition animation period, allowing you to animate between the old and new states smoothly.
Can I animate specific elements only?
Yes, use the `view-transition-name` CSS property to assign unique names to elements, then target them individually with `::view-transition-old(element-name)`. This enables granular control over which elements animate during transitions.
How long should view transitions last?
For mobile interfaces, 200-400ms is recommended. Desktop interfaces can use 300-500ms. The exact duration depends on animation complexity and device capabilities--shorter transitions feel more responsive on touch devices.
Do view transitions work offline?
Yes, once the page is loaded, view transitions work entirely client-side and don't require network requests during the animation. This makes them ideal for PWAs with offline capabilities.
Sources
- MDN Web Docs - View Transition API - Comprehensive official documentation covering all aspects including pseudo-elements
- MDN Web Docs - ::view-transition-old - Official documentation for the specific pseudo-element
- Chrome for Developers - What's new in view transitions (2025) - Latest 2025 updates including browser support and new features
- Chrome DevRel View Transitions Demos - Live demonstrations of view transition features
- CSS View Transitions Module Level 1 Specification - W3C specification for the API