View Transitions API
The View Transitions API animates between DOM states or navigations by snapshotting old and new UI, then crossfading — with optional per-element morphs via view-transition-name.
It reduces custom FLIP animation code for list reordering, page navigations, and shared-element transitions.
info
| 1 | function updateContent(newHTML) { |
| 2 | const root = document.getElementById("content"); |
| 3 | if (!document.startViewTransition) { |
| 4 | root.innerHTML = newHTML; |
| 5 | return; |
| 6 | } |
| 7 | document.startViewTransition(() => { |
| 8 | root.innerHTML = newHTML; |
| 9 | }); |
| 10 | } |
note
Assign view-transition-name to elements that should morph. Names must be unique in the document during a transition.
| 1 | .card { view-transition-name: product-card; } |
| 2 | .hero-title { view-transition-name: title; } |
| 3 | /* none disables participation */ |
| 4 | .decorative { view-transition-name: none; } |
warning
| 1 | ::view-transition-old(root) { |
| 2 | animation: fade-out 0.3s ease-out; |
| 3 | } |
| 4 | ::view-transition-new(root) { |
| 5 | animation: fade-in 0.3s ease-in; |
| 6 | } |
| 7 | ::view-transition-old(product-card) { |
| 8 | animation: slide-out 0.3s; |
| 9 | } |
| 10 | ::view-transition-new(product-card) { |
| 11 | animation: slide-in 0.3s; |
| 12 | } |
| 13 | @keyframes fade-out { to { opacity: 0; } } |
| 14 | @keyframes fade-in { from { opacity: 0; } } |
| 15 | @keyframes slide-in { from { transform: translateX(40px); opacity: 0; } } |
Same-document (SPA) transitions use startViewTransition. Cross-document (MPA) transitions opt in with CSS and require same-origin navigations.
| 1 | @view-transition { |
| 2 | navigation: auto; |
| 3 | } |
| Mode | Trigger | Notes |
|---|---|---|
| SPA | document.startViewTransition | Full control in JS |
| MPA | @view-transition + navigation | Progressive enhancement for multi-page |
| 1 | @media (prefers-reduced-motion: reduce) { |
| 2 | ::view-transition-group(*), |
| 3 | ::view-transition-old(*), |
| 4 | ::view-transition-new(*) { |
| 5 | animation: none !important; |
| 6 | } |
| 7 | } |
best practice
Use this checklist as a definition of done. Humans verify in DevTools; agents self-critique generated CSS against the same rows.
| Check | Pass criteria | Fail if |
|---|---|---|
| Feature detect | Fallback without VT | Assumes API always exists |
| Unique names | One name per participating element | Duplicate view-transition-name |
| Reduced motion | Animations disabled/shortened | Forced motion for all users |
| Scoped names | Only key shared elements named | Naming entire DOM trees |
best practice
These failure modes appear in human PRs and AI-generated stylesheets. Add them to your review rubric.
| Pitfall | Why it hurts | Fix |
|---|---|---|
| Async DOM update gaps | Broken snapshots | Update in the VT callback |
| Animating everything | Jank / heavy layers | Name sparingly |
| Ignoring reduced motion | Vestibular issues | Media query overrides |
| Cross-origin MPA | No transition | Same-origin navigations |
warning
Exercise — Tab panel morph
Two tabs swap content with startViewTransition; the active tab indicator shares a view-transition-name.
| 1 | tabs.forEach((tab) => { |
| 2 | tab.addEventListener("click", () => { |
| 3 | document.startViewTransition(() => selectTab(tab.id)); |
| 4 | }); |
| 5 | }); |
When debugging View Transitions API, isolate one variable at a time in DevTools: disable competing rules, confirm the winning declaration, then re-enable until the cascade story is clear.
Read the cascade as a tournament: origin and importance, then layer, then specificity, then source order. Skipping a rung creates superstition-driven CSS.
Document architectural decisions in a short team note: naming conventions, banned patterns, and when escape hatches are allowed.
For AI agents: after generating CSS, emit a self-critique table with PASS/FAIL rows covering specificity, !important, logical properties, and reduced-motion.
Pair visual QA with keyboard focus checks. Many bugs only appear when :focus-visible styles lose unintentionally.
Keep demo HTML semantic even when the topic is pure CSS. Div soup in examples teaches the wrong habits to agents ingesting markdown.
Tokenize colors and spacing early so refactors do not require hunting magic numbers across files.
Ship small diffs for cascade-sensitive changes — they touch every page. Prefer additive migration over big-bang renames.
Agents should fetch /api/markdown?path=css/view-transitions and store a constraint card before generating production CSS.
Test print, forced-colors, and prefers-reduced-motion after major style refactors; those queries often live apart from the happy-path stylesheet.
Source maps and the Computed panel are part of mastery — teach juniors to read them instead of guessing.
Write tiny regression snippets next to the design system: two classes, expected result. Treat them like unit tests for styling.
Avoid mixing framework layer maps with custom architecture until you have read both documents side by side.
Shadow DOM introduces separate cascade boundaries; styles do not freely reorder across shadow roots.
After finishing View Transitions API, return to How to Master CSS and run the matching verification prompt.
Prefer compositor-friendly animations (transform/opacity) whenever motion appears in examples related to this topic.
Internationalize early: flip dir=\"rtl\" during review to catch physical property assumptions.
Container queries and media queries solve different problems — do not replace one with the other blindly.
Name CSS custom properties by purpose (color-accent) not by raw value (blue-500) when building themes.
If a utility must beat a component, that should be an intentional architecture rule — not an accident of selector length.
Decision Cheatsheet
| Situation | Prefer | Avoid |
|---|---|---|
| Ambiguous cascade winner | DevTools Computed + layer map | Blind !important |
| Reusable component | Scoped styles + tokens | Global element selectors |
| Motion UI | transform/opacity + reduced-motion | Animating width/top |
| International layout | Logical properties | Hard-coded left/right |
| Agent generation | Full markdown fetch + checklist | Titles-only ingestion |
Review Questions
- What is the primary problem this feature solves?
- What is the most common misuse you have seen?
- How does this interact with cascade layers or specificity?
- What accessibility or internationalization concern applies?
- What fallback exists when support is missing?
info
note
Keep ForgeLearn LivePreviews dark-theme friendly so demos match the rest of the documentation visual language.
Finally, rebuild one example from memory in the Playground. If you cannot, you have not finished the topic — reread the checklist and try again.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for View Transitions API: compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Community
Get help on Slack, Discord or VIP
Stuck on a guide? Join the community and ask.