CKTIS / CSS
view-transition-class — shared view transition styles
The view-transition-class property assigns labels for sharing styles across view transition pseudo-elements with different names.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
view-transition-class: none | <custom-ident>+;view-transition-class accepts none or space-separated identifiers. Its initial value is none, it is not inherited, and its animation type is discrete. It does not change the HTML class attribute.
It does not enable element capture by itself: it controls styling, whereas view-transition-name identifies a transition participant and pairs its old and new states. Shared classes do not require shared names.
The selector ::view-transition-group(*.tile) selects groups with class tile. The same mechanism supports ::view-transition-image-pair(), ::view-transition-old(), and ::view-transition-new(). Multiple selector classes must all match; do not separate them with whitespace.
none cannot accompany identifiers. When a name occurs in both states, the new state's classes apply. The specification is a draft; the example requires local verification.
Examples
<!doctype html>
<meta charset="utf-8">
<title>view-transition-class</title>
<style>
.box {
view-transition-class: tile;
width: 60px;
height: 60px;
margin: 8px;
background: teal;
}
#a { view-transition-name: box-a; }
#b { view-transition-name: box-b; }
.moved .box { transform: translateX(120px); }
::view-transition-group(*.tile) { animation-duration: 1s; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(*.tile) { animation-duration: 0s; }
}
</style>
<button id="move">Move</button>
<div id="a" class="box"></div>
<div id="b" class="box"></div>
<script>
const button = document.querySelector('#move');
button.onclick = async () => {
const update = () => document.body.classList.toggle('moved');
if (!document.startViewTransition ||
!CSS.supports('view-transition-class', 'tile') ||
!CSS.supports('selector(::view-transition-group(*.tile))')) {
update();
return;
}
button.disabled = true;
try {
await document.startViewTransition(update).finished;
} finally {
button.disabled = false;
}
};
</script>Result
Clicking Move toggles both teal boxes between their original positions and positions 120px to the right. With the required support, their transition groups use a 1s animation duration; reduced-motion preference changes that duration to 0s. The fallback updates positions immediately.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.