Click a card to navigate to detail.html. The [vt] element morphs between pages. No JavaScript needed.
<a href="detail.html" vt="card-a">...</a>
<!-- detail.html: -->
<img src="..." vt="card-a" />Same grid, but using [vt-jit]. Only the element you navigate from/to gets named. The name is derived from the URL on both sides.
<a href="product.html?id=1" vt-jit>...</a>
<!-- product.html: -->
<img src="..." vt-jit />
<script src="../js/vt.js"></script>Click to swap views. Title, image, and body transition independently via document.startViewTransition().
This is the home view. Click About to transition to a different layout.
This is the about view. The browser morphs old snapshots into new positions.
<h1 vt="title">...</h1>
<p vt="body">...</p>
<script>
function spaTo(view) {
document.startViewTransition(() => {
document.querySelectorAll(".spa-view")
.forEach(v => v.classList.toggle("active", v.dataset.view === view));
});
}
</script>[vt] gives identity. [vt-class] assigns a shared animation class so many elements share one keyframe rule. Click "Animate" to swap A/B.
vt-class="fade"
vt-class="scale"
vt-class="slide-up"
vt-class="slideup"
vt-class="slide-left"
vt-class="slide-right"
<div vt="card" vt-class="fade">...</div>
<div vt="card" vt-class="scale">...</div>
<script>
document.startViewTransition(() => {
// DOM changes - vt-class handles the animation
});
</script>