CKTIS / CSS
:active-view-transition — an active view transition
The :active-view-transition pseudo-class matches the scoping element of an active view transition: the document root for a document-scoped transition, or the element defining the scope for an element-scoped transition. It lets styles depend on that state without checking the transition type.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
:active-view-transition { /* declarations */ }:active-view-transition matches the scoping element of an active view transition. For a document-scoped transition, that is the document root. For an element-scoped transition, it is the element that defines the transition’s scope. The pseudo-class does not select every animated element or start a transition itself.
It takes no arguments. Its specificity is (0,1,0); writing :root:active-view-transition adds the specificity of :root. Unlike :active-view-transition-type(), it does not check a transition type. Do not confuse it with the ::view-transition pseudo-element, which represents the transition’s visual layer.
The example uses a document-scoped transition and checks whether the document root matches the selector at three points: before calling document.startViewTransition(), immediately after that call, and immediately after calling skipTransition(). It does not wait for either the ready or the finished promise to settle. Active refers to transition state, not the general presence of CSS animations. Level 2 is a draft specification; check selector and API support separately.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Match an active view transition</title>
<style>
:root:active-view-transition #state { color: teal; }
</style>
</head>
<body>
<main><p id="state">Before update</p></main>
<script>
(() => {
const selector = ':active-view-transition';
if (!CSS.supports(`selector(${selector})`) ||
typeof document.startViewTransition !== 'function') {
console.log('Active view transition selector: unsupported');
return;
}
const root = document.documentElement;
const state = document.getElementById('state');
const before = root.matches(selector);
const transition = document.startViewTransition(() => {
state.textContent = 'After update';
});
// Skipping rejects ready; this test checks selector state, not rendering.
transition.ready.catch(() => {});
const active = root.matches(selector);
transition.skipTransition();
const after = root.matches(selector);
console.log(`Active view transition selector: supported\nBefore: ${before}\nActive: ${active}\nAfter skip: ${after}`);
})();
</script>
</body>
</html>Result
Active view transition selector: supported Before: false Active: true After skip: false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.