Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

view-transition-scope — isolating view transition names

The view-transition-scope property sets a discovery boundary for view-transition-name values when transitions originate outside a subtree.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

view-transition-scope: none | all;

none leaves name discovery unchanged. all hides non-none view-transition-name values on the element and its flat-tree descendants from transitions originating outside it. It neither starts a transition nor excludes all its content from an ancestor’s combined snapshot.

The initial value is none; the property applies to all elements and is not inherited. Animation is discrete, but its effect occurs only during name discovery.

This is a draft feature: verify behavior in your target browser. The example isolates inside while keeping outside discoverable by the document transition.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>view-transition-scope</title>
<style>
  #panel { view-transition-scope: all; }
  #inside { view-transition-name: inside; }
  #outside { view-transition-name: outside; }
</style>
<div id="panel"><p id="inside">Inside: 0</p></div>
<p id="outside">Outside: 0</p>
<button id="change">Change</button>
<script>
  const button = document.querySelector('#change');
  const inside = document.querySelector('#inside');
  const outside = document.querySelector('#outside');
  let count = 0;

  button.addEventListener('click', async () => {
    button.disabled = true;
    const update = () => {
      count += 1;
      inside.textContent = `Inside: ${count}`;
      outside.textContent = `Outside: ${count}`;
    };
    if (CSS.supports('view-transition-scope', 'all') &&
        typeof document.startViewTransition === 'function') {
      const transition = document.startViewTransition(update);
      await transition.finished.catch(() => {});
    } else {
      update();
    }
    button.disabled = false;
  });
</script>
</html>

Result

Inside: 1
Outside: 1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources