CKTIS / CSS
::view-transition — view transition tree root
The ::view-transition pseudo-element is the styleable root of a view transition tree. It lets you apply effects to the entire transition tree rather than styling the old-state and new-state images separately.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
::view-transition { /* declarations */ }::view-transition selects the browser-generated root of a view transition pseudo-element tree. It takes no argument: ::view-transition(root) is invalid. It generates boxes only when it has children.
Below it are ::view-transition-group() groups containing image pairs and ::view-transition-old() and ::view-transition-new(). An effect set on the root, such as filter, affects the entire tree. The selector does not start a transition; the example uses document.startViewTransition() for that.
For a whole-document transition, the transition layer paints above the remaining content, including the top layer. The Level 2 draft also describes element-scoped transitions; do not infer their support from document-transition support. @view-transition is a separate rule that enables cross-document transitions, not this pseudo-element.
In the example, the filter temporarily removes colors from the transition overlay, not from the persistent page content. Without the API, the text still changes. The reduced-motion preference shortens the animation to zero. Local verification is required; an editor’s draft does not establish support in a particular browser version.
Examples
<!doctype html>
<meta charset="utf-8">
<title>View transition root</title>
<style>
body { font: 1.25rem sans-serif; }
::view-transition { filter: grayscale(1); }
::view-transition-group(root) { animation-duration: 1s; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(root) { animation-duration: 0s; }
}
#state { color: #b00020; }
</style>
<button id="change" type="button">Change</button>
<p id="state">Before</p>
<script>
const button = document.querySelector('#change');
const state = document.querySelector('#state');
button.addEventListener('click', async () => {
button.disabled = true;
const update = () => { state.textContent = 'After'; };
if (typeof document.startViewTransition !== 'function') {
update();
return;
}
const transition = document.startViewTransition(update);
await transition.finished;
});
</script>Result
Initially: Before. After clicking Change: After; the button remains disabled. If the visual transition runs, its overlay is grayscale during the transition; afterward, After is red.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.