View Transition Builderとは
The View Transitions API creates smooth animated transitions when navigating between pages or updating page content. The browser captures screenshots of the old and new states, then crossfades between them. You can assign view-transition-name to specific elements to animate them independently during the transition. For same-document transitions (SPAs), use document.startViewTransition(). For cross-document (MPAs), add a meta tag.
クイックアンサー
Use the View Transitions API for smooth page and element animations. For SPAs: document.startViewTransition(() => updateDOM()). For MPAs: add <meta name="view-transition" content="same-origin"> to the head. Assign view-transition-name to elements for independent animation. Always respect prefers-reduced-motion.
制限事項
- Cross-document (MPA) transitions only work between same-origin pages. Cross-origin navigation does not trigger a view transition, even with the meta tag.
- The browser captures static screenshots of the old and new states. Live content like videos, animations, or continuously updating elements may appear frozen during the transition.
- View Transitions are Baseline 2025: Chrome 111+, Edge 111+, Safari 18.2+. Firefox support is in development. Unsupported browsers navigate without animation — the feature degrades gracefully.
使い方
- Choose the transition type: same-document (for SPA content updates) or cross-document (for MPA page navigation).
- Set animation duration, easing, and the view-transition-name for elements that should animate independently.
- Optionally customize the ::view-transition-new and ::view-transition-old pseudo-elements.
- Copy the CSS and JavaScript/meta tag. Enable prefers-reduced-motion fallback for accessibility.
主な用途
- Animate a hero image between a list page and a detail page using the same view-transition-name on both pages.
- Add a smooth crossfade when navigating between pages in a static site by adding the view-transition meta tag.
- Animate a gallery filter: call startViewTransition() before updating the image grid for a smooth layout change.