Page Transitions With the View Transitions API
Updated 2026-10-16. 8 effects.
A page transition animates the change from one page or view to the next instead of cutting. The View Transitions API does this natively: call document.startViewTransition() around the update, then style the old and new snapshots with CSS. Each transition below uses that where supported and a short transform and opacity fallback elsewhere.
Match the transition to how far the visitor is going. Moving between sibling pages suits a quick slide in the reading direction; opening an item from a grid suits a shared-image morph where the thumbnail grows into the hero; switching sections of a single page suits a crossfade. Anything longer than about half a second starts to feel like waiting.
Same-page transitions work in current Chrome, Edge, Firefox and Safari. Transitions between separate HTML pages use the @view-transition rule, which Chrome, Edge and Safari support today and Firefox does not yet. In the previews, each piece switches views inside its own box so you can try it; the comments show how to apply it to real navigation.
Compare them
| Effect | Built with | Size (gzipped) | Running cost | Browser support |
|---|---|---|---|---|
| Article Rows Cascade Out and In Between Sections | CSS and a small script | 3.8 KB | Five small snapshots fade and shift for about half a second; keep the named rows to the ones on screen. | All current browsers; instant swap in older ones |
| Booking Steps Push Up With a Filling Progress Bar | CSS and a small script | 4.5 KB | The form area is captured twice and pushed by transform for half a second, and the bar fills with one scale transition. | All current browsers; instant swap in older ones |
| Grid Thumbnail Grows Into the Detail Photo | CSS and a small script | 4.4 KB | One captured photo moves by transform for about half a second while the page crossfades; idle cost is zero. | All current browsers; instant swap in older ones |
| Menu Zooms Into Each Course and Back Out | CSS and a small script | 3.8 KB | Two snapshots of the page area scale and fade for about half a second; the menu costs nothing while it sits still. | All current browsers; instant swap in older ones |
| New Page Slides Up Over the Old One | CSS and a small script | 3.8 KB | Two snapshots of the content area move for about six tenths of a second; nothing runs while a page is open. | All current browsers; instant swap in older ones |
| Page Tabs With Gliding Underline and Rising Content | CSS and a small script | 3.8 KB | One thin bar and one content snapshot move by transform for under half a second; there is no work between clicks. | All current browsers; instant swap in older ones |
| Sibling Pages Slide in Reading Direction | CSS and a small script | 3.9 KB | The browser slides two snapshots of one area for half a second; nothing runs between page changes. | All current browsers; instant swap in older ones |
| Split Columns Slide in Opposite Directions | CSS and a small script | 3.8 KB | Four snapshots, two per column, move by transform for just over half a second, then the page is static again. | All current browsers; instant swap in older ones |
Article Rows Cascade Out and In Between Sections
A quarterly journal in warm ink tones with three sections of articles. Switching section sends the heading and each article row out one after another, then brings the new rows in with the same short cascade, a little like pages being dealt. Each row is its own named part, which is what lets them move on separate delays.
<div class="w6stg" data-w6stg>
<header class="w6stg-top">
<p class="w6stg-brand">The Long Field <span>Journal</span></p>
<nav aria-label="Journal sections">
<ul class="w6stg-nav">
<li><a href="#" data-go="0" data-nav aria-current="page">Latest</a></li>
<li><a href="#" data-go="1" data-nav>Essays</a></li>
<li><a href="#" data-go="2" data-nav>Interviews</a></li>
</ul>
</nav>
</header>
<div class="w6stg-stage">
<section class="w6stg-view" aria-labelledby="w6stg-h0">
<div class="w6stg-head" data-vt="w6stg-head">
<h2 id="w6stg-h0" tabindex="-1">Latest</h2>
<p>Autumn issue, out now</p>
</div>
<ol class="w6stg-rows">
<li data-vt="w6stg-r1"><a href="#"><span class="w6stg-n" aria-hidden="true">01</span><b>The year the river moved</b><small>Hana Okafor · 14 min read</small></a></li>
<li data-vt="w6stg-r2"><a href="#"><span class="w6stg-n" aria-hidden="true">02</span><b>Notes on mending a dry stone wall</b><small>Pete Garroway · 9 min read</small></a></li>
<li data-vt="w6stg-r3"><a href="#"><span class="w6stg-n" aria-hidden="true">03</span><b>What the hedgerow remembers</b><small>Lin Marsh · 11 min read</small></a></li>
<li data-vt="w6stg-r4"><a href="#"><span class="w6stg-n" aria-hidden="true">04</span><b>A field guide to October light</b><small>Ruth Sallow · 6 min read</small></a></li>
</ol>
</section>
<section class="w6stg-view" aria-labelledby="w6stg-h1" hidden>
<div class="w6stg-head" data-vt="w6stg-head">
<h2 id="w6stg-h1" tabindex="-1">Essays</h2>
<p>Long reads from the back pages</p>
</div>
<ol class="w6stg-rows">
<li data-vt="w6stg-r1"><a href="#"><span class="w6stg-n" aria-hidden="true">01</span><b>Against tidy gardens</b><small>Owen Brack · 18 min read</small></a></li>
<li data-vt="w6stg-r2"><a href="#"><span class="w6stg-n" aria-hidden="true">02</span><b>The economics of a village shop</b><small>Dee Annand · 16 min read</small></a></li>
<li data-vt="w6stg-r3"><a href="#"><span class="w6stg-n" aria-hidden="true">03</span><b>On walking the same path for ten years</b><small>Hana Okafor · 12 min read</small></a></li>
<li data-vt="w6stg-r4"><a href="#"><span class="w6stg-n" aria-hidden="true">04</span><b>Weather as a second language</b><small>Cal Peary · 10 min read</small></a></li>
</ol>
</section>
<section class="w6stg-view" aria-labelledby="w6stg-h2" hidden>
<div class="w6stg-head" data-vt="w6stg-head">
<h2 id="w6stg-h2" tabindex="-1">Interviews</h2>
<p>Conversations at kitchen tables</p>
</div>
<ol class="w6stg-rows">
<li data-vt="w6stg-r1"><a href="#"><span class="w6stg-n" aria-hidden="true">01</span><b>A shepherd on losing the hill farm</b><small>with Morag Telfer · 21 min read</small></a></li>
<li data-vt="w6stg-r2"><a href="#"><span class="w6stg-n" aria-hidden="true">02</span><b>The last thatcher in the valley</b><small>with Ivo Penhale · 15 min read</small></a></li>
<li data-vt="w6stg-r3"><a href="#"><span class="w6stg-n" aria-hidden="true">03</span><b>Running a ferry with one engine</b><small>with Sue Rendle · 13 min read</small></a></li>
<li data-vt="w6stg-r4"><a href="#"><span class="w6stg-n" aria-hidden="true">04</span><b>Bees, bookkeeping and patience</b><small>with Amit Dhar · 17 min read</small></a></li>
</ol>
</section>
</div>
<p class="w6stg-foot">Printed four times a year on uncoated paper. <a href="#">Subscribe for £36</a></p>
</div>
<style>
/* Change these: --w6stg-ink (background), --w6stg-paper (text), --w6stg-amber (accent), the 40ms delay steps
between rows further down, and the 28px travel in the w6stg keyframes. */
.w6stg { --w6stg-ink: #151412; --w6stg-paper: #eee7db; --w6stg-amber: #dba468;
height: 560px; display: flex; flex-direction: column; background: var(--w6stg-ink); color: var(--w6stg-paper);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6stg *, .w6stg *::before { box-sizing: border-box; }
.w6stg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; padding: 18px clamp(16px, 5vw, 56px); border-bottom: 1px solid #2c2a26; }
.w6stg-brand { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-size: 1.2rem; font-style: italic; }
.w6stg-brand span { font-family: ui-sans-serif, system-ui, sans-serif; font-style: normal; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: #a39b8e; margin-left: 4px; }
.w6stg-nav { display: flex; gap: 4px; margin: 0 -10px; padding: 0; list-style: none; }
.w6stg-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; color: #b5ad9f; font-size: .9375rem; text-decoration: none; border-radius: 4px; }
.w6stg-nav a:hover { color: var(--w6stg-paper); }
.w6stg-nav a[aria-current="page"] { color: var(--w6stg-amber); }
.w6stg a:focus-visible, .w6stg h2:focus-visible { outline: 2px solid var(--w6stg-amber); outline-offset: 3px; }
.w6stg h2:focus { outline: none; }
.w6stg-stage { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 26px clamp(16px, 5vw, 56px) 8px; }
.w6stg-view[hidden] { display: none; }
.w6stg-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; }
.w6stg h2 { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1; letter-spacing: -.02em; }
.w6stg-head p { margin: 0; font-size: .875rem; color: #a39b8e; }
.w6stg-rows { margin: 18px 0 0; padding: 0; list-style: none; border-top: 1px solid #34312c; }
.w6stg-rows li { border-bottom: 1px solid #34312c; background: var(--w6stg-ink); }
.w6stg-rows a { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: 2px 14px; padding: 15px 2px; color: inherit; text-decoration: none; border-radius: 4px; }
.w6stg-n { grid-row: span 2; padding-top: 4px; font-size: .75rem; color: var(--w6stg-amber); font-variant-numeric: tabular-nums; }
.w6stg-rows b { font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.05rem, 2vw, 1.3rem); line-height: 1.3; }
.w6stg-rows small { font-size: .8125rem; color: #a39b8e; }
.w6stg-rows a:hover b { color: #fff; text-decoration: underline; text-decoration-color: var(--w6stg-amber); text-underline-offset: 4px; }
.w6stg-foot { margin: 0; padding: 14px clamp(16px, 5vw, 56px) 18px; border-top: 1px solid #2c2a26; font-size: .875rem; color: #b5ad9f; }
.w6stg-foot a { color: var(--w6stg-amber); text-underline-offset: 4px; }
@media (min-width: 860px) {
.w6stg-rows a { grid-template-columns: 3rem minmax(0, 1fr) auto; align-items: baseline; }
.w6stg-n { grid-row: auto; }
}
/* The heading and each row carry their own name during the change, so they can leave and arrive one after another.
Forward rows exit left and enter from the right; back reverses it. Delays step by 40ms per row.
Separate pages: add @view-transition { navigation: auto; } and the same names on every page. */
::view-transition-group(w6stg-head), ::view-transition-group(w6stg-r1), ::view-transition-group(w6stg-r2),
::view-transition-group(w6stg-r3), ::view-transition-group(w6stg-r4) { animation: none; }
::view-transition-old(w6stg-head), ::view-transition-old(w6stg-r1), ::view-transition-old(w6stg-r2), ::view-transition-old(w6stg-r3), ::view-transition-old(w6stg-r4) {
mix-blend-mode: normal; animation: w6stg-out .2s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(w6stg-head), ::view-transition-new(w6stg-r1), ::view-transition-new(w6stg-r2), ::view-transition-new(w6stg-r3), ::view-transition-new(w6stg-r4) {
mix-blend-mode: normal; animation: w6stg-in .4s .18s cubic-bezier(.2, .8, .2, 1) both; }
::view-transition-old(w6stg-r1) { animation-delay: 40ms; } ::view-transition-new(w6stg-r1) { animation-delay: .22s; }
::view-transition-old(w6stg-r2) { animation-delay: 80ms; } ::view-transition-new(w6stg-r2) { animation-delay: .26s; }
::view-transition-old(w6stg-r3) { animation-delay: 120ms; } ::view-transition-new(w6stg-r3) { animation-delay: .3s; }
::view-transition-old(w6stg-r4) { animation-delay: 160ms; } ::view-transition-new(w6stg-r4) { animation-delay: .34s; }
:root[data-w6stg-dir="b"]::view-transition-old(w6stg-head), :root[data-w6stg-dir="b"]::view-transition-old(w6stg-r1), :root[data-w6stg-dir="b"]::view-transition-old(w6stg-r2),
:root[data-w6stg-dir="b"]::view-transition-old(w6stg-r3), :root[data-w6stg-dir="b"]::view-transition-old(w6stg-r4) { animation-name: w6stg-out-b; }
:root[data-w6stg-dir="b"]::view-transition-new(w6stg-head), :root[data-w6stg-dir="b"]::view-transition-new(w6stg-r1), :root[data-w6stg-dir="b"]::view-transition-new(w6stg-r2),
:root[data-w6stg-dir="b"]::view-transition-new(w6stg-r3), :root[data-w6stg-dir="b"]::view-transition-new(w6stg-r4) { animation-name: w6stg-in-b; }
@keyframes w6stg-out { to { opacity: 0; transform: translateX(-28px); } }
@keyframes w6stg-in { from { opacity: 0; transform: translateX(28px); } }
@keyframes w6stg-out-b { to { opacity: 0; transform: translateX(28px); } }
@keyframes w6stg-in-b { from { opacity: 0; transform: translateX(-28px); } }
/* Fallback without view transitions: new rows arrive in the same cascade. */
.w6stg[data-fb] .w6stg-view:not([hidden]) .w6stg-head, .w6stg[data-fb] .w6stg-view:not([hidden]) li { animation: w6stg-in .46s cubic-bezier(.2, .8, .2, 1) both; }
.w6stg[data-fb] .w6stg-view:not([hidden]) li:nth-child(2) { animation-delay: 40ms; }
.w6stg[data-fb] .w6stg-view:not([hidden]) li:nth-child(3) { animation-delay: 80ms; }
.w6stg[data-fb] .w6stg-view:not([hidden]) li:nth-child(4) { animation-delay: 120ms; }
@media (prefers-reduced-motion: reduce) {
::view-transition-old(w6stg-head), ::view-transition-new(w6stg-head), ::view-transition-old(w6stg-r1), ::view-transition-new(w6stg-r1),
::view-transition-old(w6stg-r2), ::view-transition-new(w6stg-r2), ::view-transition-old(w6stg-r3), ::view-transition-new(w6stg-r3),
::view-transition-old(w6stg-r4), ::view-transition-new(w6stg-r4) { animation: none; }
.w6stg .w6stg-head, .w6stg .w6stg-view li { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6stg]");
if (!root) return;
//BODY-START
var DEMO = [700, 1800, 3000]; // idle demo: ms before each automatic section change; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6stg-stage");
var views = root.querySelectorAll(".w6stg-view"), navs = root.querySelectorAll("[data-nav]");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
// Gives (or takes away) the heading and rows of a view their view-transition-name from data-vt.
function tag(v, on) { v.querySelectorAll("[data-vt]").forEach(function (n) { n.style.viewTransitionName = on ? n.getAttribute("data-vt") : ""; }); }
function go(i, person) {
if (i === cur || busy) return;
var dir = i > cur ? "f" : "b", was = views[cur], vt = !!document.startViewTransition;
var swap = function () {
tag(was, false); was.hidden = true; views[i].hidden = false; if (vt) tag(views[i], true);
navs.forEach(function (a, k) { if (k === i) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current"); });
cur = i; stage.scrollTop = 0;
if (person) views[i].querySelector("h2").focus({ preventScroll: true });
};
if (rm.matches) return swap();
if (vt) {
busy = true; tag(was, true);
html.setAttribute("data-w6stg-dir", dir);
document.startViewTransition(swap).finished.finally(function () { tag(views[i], false); html.removeAttribute("data-w6stg-dir"); busy = false; });
} else { root.setAttribute("data-fb", ""); swap(); }
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: moves through the sections while the piece is on screen and nobody has used it.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go((cur + 1) % views.length, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: The new section and its rows replace the old ones straight away, with no cascade.
Running cost: Five small snapshots fade and shift for about half a second; keep the named rows to the ones on screen.
- Change the 40ms steps in the `animation-delay` rules for `w6stg-r1` to `w6stg-r4` to tighten or loosen the cascade.
- Set `--w6stg-amber` on `.w6stg` for the active section, row numbers and focus ring.
- For more rows, add `w6stg-r5` with its own delay and the matching `data-vt` attribute.
Booking Steps Push Up With a Filling Progress Bar
A three-step room booking for a seaside guesthouse in sand tones. Continuing pushes the finished step up and out while the next one rises from below, and the thin bar in the header fills a third at a time; going back pushes the other way. The summary step reads the dates and room you picked.
<div class="w6stp" data-w6stp>
<header class="w6stp-top">
<p class="w6stp-brand">Marram House <span>Rooms by the dunes</span></p>
<div class="w6stp-prog">
<p class="w6stp-count" aria-live="polite">Step <b>1</b> of 3</p>
<div class="w6stp-track" aria-hidden="true"><span class="w6stp-fill"></span></div>
</div>
</header>
<div class="w6stp-body">
<div class="w6stp-stage">
<section class="w6stp-view" aria-labelledby="w6stp-h0">
<h2 id="w6stp-h0" tabindex="-1">When are you coming?</h2>
<p class="w6stp-lead">These weekends still have rooms. Check-in from 3pm, breakfast until 10.</p>
<fieldset class="w6stp-opts">
<legend class="w6stp-sr">Dates</legend>
<label for="w6stp-d0"><input type="radio" id="w6stp-d0" name="w6stp-d" value="Fri 7 to Sun 9 Nov" data-n="2" checked><span><b>Fri 7 to Sun 9 Nov</b><small>2 nights</small></span></label>
<label for="w6stp-d1"><input type="radio" id="w6stp-d1" name="w6stp-d" value="Fri 14 to Mon 17 Nov" data-n="3"><span><b>Fri 14 to Mon 17 Nov</b><small>3 nights</small></span></label>
<label for="w6stp-d2"><input type="radio" id="w6stp-d2" name="w6stp-d" value="Thu 20 to Sun 23 Nov" data-n="3"><span><b>Thu 20 to Sun 23 Nov</b><small>3 nights</small></span></label>
</fieldset>
<p class="w6stp-btns"><button type="button" class="w6stp-go" data-go="1">Choose a room</button></p>
</section>
<section class="w6stp-view" aria-labelledby="w6stp-h1" hidden>
<h2 id="w6stp-h1" tabindex="-1">Pick a room</h2>
<div class="w6stp-room">
<img src="https://images.pexels.com/photos/2736388/pexels-photo-2736388.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A made-up double bed with white linen, a padded headboard and a lit bedside lamp" width="600" height="400">
<fieldset class="w6stp-opts">
<legend class="w6stp-sr">Room</legend>
<label for="w6stp-r0"><input type="radio" id="w6stp-r0" name="w6stp-r" value="Dune Room" data-p="140" checked><span><b>Dune Room</b><small>Sea view, king bed, £140 a night</small></span></label>
<label for="w6stp-r1"><input type="radio" id="w6stp-r1" name="w6stp-r" value="Garden Room" data-p="115"><span><b>Garden Room</b><small>Own terrace, double bed, £115 a night</small></span></label>
</fieldset>
</div>
<p class="w6stp-btns"><button type="button" class="w6stp-back" data-go="0">Back</button><button type="button" class="w6stp-go" data-go="2">Check details</button></p>
</section>
<section class="w6stp-view" aria-labelledby="w6stp-h2" hidden>
<h2 id="w6stp-h2" tabindex="-1">Check and send</h2>
<dl class="w6stp-sum">
<div><dt>Dates</dt><dd data-sum="d">Fri 7 to Sun 9 Nov</dd></div>
<div><dt>Room</dt><dd data-sum="r">Dune Room</dd></div>
<div><dt>Total</dt><dd data-sum="t">£280 with breakfast</dd></div>
</dl>
<label class="w6stp-field" for="w6stp-name">Your name</label>
<input class="w6stp-input" id="w6stp-name" type="text" autocomplete="name" placeholder="As on your card">
<p class="w6stp-btns"><button type="button" class="w6stp-back" data-go="1">Back</button><button type="button" class="w6stp-go" data-send>Request these dates</button></p>
<p class="w6stp-note" aria-live="polite"></p>
</section>
</div>
<aside class="w6stp-aside" aria-label="About the house">
<h3>Eight rooms behind the dunes</h3>
<p>Two minutes from the beach path at Shore Road, Holme, with breakfast from the farm next door.</p>
<ul><li>Check-in 3pm, check-out 11am</li><li>Dogs welcome in garden rooms</li><li>Arrival from 3pm on the first day</li></ul>
</aside>
</div>
</div>
<style>
/* Change these: --w6stp-sand, --w6stp-ink, --w6stp-rust (accent), the 32% push in the w6stp keyframes
and the .5s durations. */
.w6stp { --w6stp-sand: #f1e9db; --w6stp-ink: #2f271d; --w6stp-rust: #9a4f24;
height: 620px; display: flex; flex-direction: column; background: var(--w6stp-sand); color: var(--w6stp-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6stp *, .w6stp *::before { box-sizing: border-box; }
.w6stp-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; padding: 18px clamp(16px, 5vw, 56px); border-bottom: 1px solid #dccfb9; }
.w6stp-brand { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-size: 1.2rem; }
.w6stp-brand span { display: block; font-family: ui-sans-serif, system-ui, sans-serif; font-size: .75rem; color: #6b5c49; }
.w6stp-prog { width: min(260px, 100%); }
.w6stp-count { margin: 0 0 8px; font-size: .8125rem; color: #5c4e3d; }
.w6stp-track { height: 4px; border-radius: 4px; background: #ddd0bb; overflow: hidden; }
.w6stp-fill { display: block; height: 100%; background: var(--w6stp-rust); transform-origin: 0 50%; transform: scaleX(.3333); transition: transform .6s cubic-bezier(.3, .8, .2, 1); }
.w6stp-body { flex: 1; min-height: 0; display: flex; }
.w6stp-stage { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; }
.w6stp-aside { display: none; }
@media (min-width: 980px) {
.w6stp-aside { display: block; flex: 0 0 17rem; align-self: start; margin: 26px clamp(16px, 5vw, 56px) 0 0; padding: 20px; border-radius: 14px; background: #faf6ef; border: 1px solid #e2d6c3; }
.w6stp-aside h3 { margin: 0; font-family: Georgia, serif; font-weight: 400; font-size: 1.15rem; }
.w6stp-aside p { margin: 8px 0 0; font-size: .875rem; line-height: 1.55; color: #574937; }
.w6stp-aside ul { margin: 12px 0 0; padding: 12px 0 0; list-style: none; border-top: 1px solid #e2d6c3; display: grid; gap: 6px; font-size: .8125rem; color: #4a3d2e; }
}
.w6stp-view { padding: 26px clamp(16px, 5vw, 56px) 28px; max-width: 46rem; }
.w6stp-view[hidden] { display: none; }
.w6stp h2 { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(1.7rem, 3.6vw, 2.4rem); line-height: 1.1; }
.w6stp h2:focus { outline: none; }
.w6stp h2:focus-visible { outline: 2px solid var(--w6stp-rust); outline-offset: 4px; }
.w6stp-lead { margin: 10px 0 0; font-size: 1rem; line-height: 1.55; color: #574937; }
.w6stp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.w6stp-opts { margin: 18px 0 0; padding: 0; border: 0; display: grid; gap: 10px; }
.w6stp-opts label { position: relative; display: block; cursor: pointer; }
.w6stp-opts input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.w6stp-opts span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; align-items: baseline; min-height: 54px; padding: 15px 18px 15px 46px;
border: 1px solid #d6c7ae; border-radius: 12px; background: #faf6ef; }
.w6stp-opts span::before { content: ""; position: absolute; left: 17px; top: 18px; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #8c7a62; background: #fff; }
.w6stp-opts input:checked + span { border-color: var(--w6stp-rust); background: #fff; box-shadow: 0 0 0 1px var(--w6stp-rust); }
.w6stp-opts input:checked + span::before { border: 5px solid var(--w6stp-rust); }
.w6stp-opts input:focus-visible + span { outline: 2px solid var(--w6stp-ink); outline-offset: 2px; }
.w6stp-opts b { font-weight: 600; font-size: .9375rem; }
.w6stp-opts small { font-size: .8125rem; color: #6b5c49; }
.w6stp-room { display: grid; gap: 14px; margin-top: 18px; }
.w6stp-room img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; background: #e3d6c1; }
.w6stp-room .w6stp-opts { margin: 0; align-content: start; }
.w6stp-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; }
.w6stp button { min-height: 46px; padding: 0 22px; border-radius: 999px; font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; }
.w6stp-go { border: 0; background: var(--w6stp-rust); color: #fff; }
.w6stp-go:hover { background: #80411d; }
.w6stp-back { border: 1px solid #b9a88f; background: transparent; color: var(--w6stp-ink); }
.w6stp button:focus-visible, .w6stp-input:focus-visible { outline: 2px solid var(--w6stp-ink); outline-offset: 3px; }
.w6stp-sum { margin: 18px 0 0; border-top: 1px solid #dccfb9; }
.w6stp-sum div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid #dccfb9; font-size: .9375rem; }
.w6stp-sum dt { color: #6b5c49; }
.w6stp-sum dd { margin: 0; font-weight: 600; text-align: right; }
.w6stp-field { display: block; margin-top: 18px; font-size: .875rem; font-weight: 600; }
.w6stp-input { display: block; width: 100%; max-width: 22rem; min-height: 46px; margin-top: 6px; padding: 0 14px; border: 1px solid #b9a88f; border-radius: 10px; background: #fff; font: inherit; color: inherit; }
.w6stp-note { margin: 12px 0 0; min-height: 1.4em; font-size: .9375rem; color: #3f6b3a; }
@media (min-width: 760px) { .w6stp-room { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
/* The step area is named only during a change: forward pushes the old step up and out while the next rises
from below; back pushes downwards. The bar fill is named too and keeps its live CSS transition.
Real multi-page forms: add @view-transition { navigation: auto; } and these names on each page. */
::view-transition-group(w6stp-stage) { animation: none; overflow: clip; }
::view-transition-group(w6stp-fill) { animation: none; }
::view-transition-old(w6stp-fill) { animation: none; opacity: 0; }
::view-transition-new(w6stp-fill) { animation: none; }
::view-transition-old(w6stp-stage), ::view-transition-new(w6stp-stage) { mix-blend-mode: normal; }
::view-transition-old(w6stp-stage) { animation: w6stp-up-out .3s cubic-bezier(.4, 0, .9, .6) both; }
::view-transition-new(w6stp-stage) { animation: w6stp-up-in .5s .06s cubic-bezier(.2, .8, .2, 1) both; }
:root[data-w6stp-dir="b"]::view-transition-old(w6stp-stage) { animation-name: w6stp-down-out; }
:root[data-w6stp-dir="b"]::view-transition-new(w6stp-stage) { animation-name: w6stp-down-in; }
@keyframes w6stp-up-out { to { opacity: 0; transform: translateY(-32%); } }
@keyframes w6stp-up-in { from { opacity: 0; transform: translateY(32%); } }
@keyframes w6stp-down-out { to { opacity: 0; transform: translateY(32%); } }
@keyframes w6stp-down-in { from { opacity: 0; transform: translateY(-32%); } }
.w6stp[data-fb="f"] .w6stp-view:not([hidden]) { animation: w6stp-up-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.w6stp[data-fb="b"] .w6stp-view:not([hidden]) { animation: w6stp-down-in .45s cubic-bezier(.2, .8, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6stp-stage), ::view-transition-old(w6stp-stage), ::view-transition-new(w6stp-stage) { animation: none; }
.w6stp .w6stp-view { animation: none !important; }
.w6stp-fill { transition: none; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6stp]");
if (!root) return;
//BODY-START
var DEMO = [800, 1800, 2600, 2600]; // idle demo: ms before each automatic step; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6stp-stage"), fill = root.querySelector(".w6stp-fill");
var views = root.querySelectorAll(".w6stp-view"), count = root.querySelector(".w6stp-count b");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
// Copies the chosen dates and room into the summary step.
function sum() {
var d = root.querySelector("[name=w6stp-d]:checked"), r = root.querySelector("[name=w6stp-r]:checked");
root.querySelector('[data-sum="d"]').textContent = d.value;
root.querySelector('[data-sum="r"]').textContent = r.value;
root.querySelector('[data-sum="t"]').textContent = "£" + d.getAttribute("data-n") * r.getAttribute("data-p") + " with breakfast";
}
function show(i) {
if (i === 2) sum();
views.forEach(function (v, k) { v.hidden = k !== i; });
fill.style.transform = "scaleX(" + (i + 1) / 3 + ")";
count.textContent = i + 1;
cur = i; stage.scrollTop = 0;
}
function go(i, person) {
if (i === cur || busy) return;
var dir = i > cur ? "f" : "b";
var swap = function () { show(i); if (person) views[i].querySelector("h2").focus({ preventScroll: true }); };
if (rm.matches) return swap();
if (document.startViewTransition) {
busy = true;
stage.style.viewTransitionName = "w6stp-stage"; fill.style.viewTransitionName = "w6stp-fill";
html.setAttribute("data-w6stp-dir", dir);
document.startViewTransition(swap).finished.finally(function () {
stage.style.viewTransitionName = fill.style.viewTransitionName = ""; html.removeAttribute("data-w6stp-dir"); busy = false;
});
} else { root.setAttribute("data-fb", dir); swap(); }
}
root.addEventListener("click", function (e) {
var b = e.target.closest("[data-go],[data-send]");
if (!b) return;
auto = false;
if (b.hasAttribute("data-send")) root.querySelector(".w6stp-note").textContent = "Request sent. We reply by email within a few hours.";
else go(+b.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: walks forward through the steps, then back to the start, while on screen and untouched.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go(cur < 2 ? cur + 1 : 0, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: Each step replaces the last in one go and the progress bar moves without easing.
Running cost: The form area is captured twice and pushed by transform for half a second, and the bar fills with one scale transition.
- Change the `32%` in the four `w6stp` push keyframes to make steps travel further or less.
- Recolour the bar, chosen options and main buttons with `--w6stp-rust` on `.w6stp`.
- Edit the dates and rooms in the radio lists; `data-n` (nights) times `data-p` (price) gives the total.
Grid Thumbnail Grows Into the Detail Photo
A pottery studio shop where opening a piece makes its small grid photo grow and travel into the large photo on the detail page, while the rest of the page crossfades. Going back shrinks it into its card again. Card and detail photos share one shape, so the move is a single even scale with nothing stretched.
<div class="w6mph" data-w6mph>
<header class="w6mph-top">
<p class="w6mph-brand">Ochre Lane <span>Pottery</span></p>
<p class="w6mph-note">Studio sale, this weekend only</p>
</header>
<div class="w6mph-stage">
<section class="w6mph-view w6mph-grid" aria-labelledby="w6mph-h0">
<h2 id="w6mph-h0" tabindex="-1">From this week's firing</h2>
<p class="w6mph-intro">Four small batches out of the kiln on Thursday. Open a piece to see its glaze, size and how to look after it.</p>
<ul class="w6mph-cards">
<li><a href="#" data-go="1"><img src="https://images.pexels.com/photos/33703946/pexels-photo-33703946.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Stacks of rustic clay bowls on workshop shelves" width="600" height="400"><b>Hearth bowl</b><span>£24 each</span></a></li>
<li><a href="#" data-go="2"><img src="https://images.pexels.com/photos/8063882/pexels-photo-8063882.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Ceramic vases dipped in grey, coral and white glaze on a wooden shelf" width="600" height="400"><b>Dipped bud vase</b><span>£36</span></a></li>
<li><a href="#" data-go="3"><img src="https://images.pexels.com/photos/28271468/pexels-photo-28271468.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Small dishes with a deep teal glaze laid out on a white cloth" width="600" height="400"><b>Tidepool dish</b><span>£22</span></a></li>
<li><a href="#" data-go="4"><img src="https://images.pexels.com/photos/8063803/pexels-photo-8063803.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Rows of unglazed white mugs on a dusty studio shelf" width="600" height="400"><b>Bisque mug</b><span>£18</span></a></li>
</ul>
<p class="w6mph-foot">Collect from the studio door on Saturday, 10am to 4pm, or we can post your order.</p>
</section>
<section class="w6mph-view" aria-labelledby="w6mph-h1" hidden>
<p class="w6mph-crumbs"><a href="#" data-go="0">All pieces</a><a href="#" data-go="2">Next piece</a></p>
<div class="w6mph-split">
<img class="w6mph-hero" src="https://images.pexels.com/photos/33703946/pexels-photo-33703946.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Stacks of rustic clay bowls on workshop shelves" width="600" height="400">
<div class="w6mph-txt">
<h2 id="w6mph-h1" tabindex="-1">Hearth bowl</h2>
<p class="w6mph-price">£24 each</p>
<p class="w6mph-desc">Wide enough for soup, shallow enough for salad.</p>
<dl class="w6mph-facts">
<div><dt>Size</dt><dd>15 cm across, 7 cm deep</dd></div>
<div><dt>Glaze</dt><dd>Bare clay outside, honey glaze inside</dd></div>
<div><dt>Care</dt><dd>Wash by hand</dd></div>
</dl>
<button type="button" class="w6mph-btn">Reserve this piece</button>
</div>
</div>
</section>
<section class="w6mph-view" aria-labelledby="w6mph-h2" hidden>
<p class="w6mph-crumbs"><a href="#" data-go="0">All pieces</a><a href="#" data-go="3">Next piece</a></p>
<div class="w6mph-split">
<img class="w6mph-hero" src="https://images.pexels.com/photos/8063882/pexels-photo-8063882.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Ceramic vases dipped in grey, coral and white glaze on a wooden shelf" width="600" height="400">
<div class="w6mph-txt">
<h2 id="w6mph-h2" tabindex="-1">Dipped bud vase</h2>
<p class="w6mph-price">£36</p>
<p class="w6mph-desc">Dipped twice by hand, so no two bands sit at the same height.</p>
<dl class="w6mph-facts">
<div><dt>Size</dt><dd>18 cm tall</dd></div>
<div><dt>Glaze</dt><dd>Grey, coral or white over a raw foot</dd></div>
<div><dt>Care</dt><dd>Rinse by hand</dd></div>
</dl>
<button type="button" class="w6mph-btn">Reserve this piece</button>
</div>
</div>
</section>
<section class="w6mph-view" aria-labelledby="w6mph-h3" hidden>
<p class="w6mph-crumbs"><a href="#" data-go="0">All pieces</a><a href="#" data-go="4">Next piece</a></p>
<div class="w6mph-split">
<img class="w6mph-hero" src="https://images.pexels.com/photos/28271468/pexels-photo-28271468.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Small dishes with a deep teal glaze laid out on a white cloth" width="600" height="400">
<div class="w6mph-txt">
<h2 id="w6mph-h3" tabindex="-1">Tidepool dish</h2>
<p class="w6mph-price">£22</p>
<p class="w6mph-desc">For olives, salt or rings by the sink. The teal pools darker where the glaze runs thick.</p>
<dl class="w6mph-facts">
<div><dt>Size</dt><dd>11 cm across</dd></div>
<div><dt>Glaze</dt><dd>Reactive teal with an iron edge</dd></div>
<div><dt>Care</dt><dd>Wash by hand</dd></div>
</dl>
<button type="button" class="w6mph-btn">Reserve this piece</button>
</div>
</div>
</section>
<section class="w6mph-view" aria-labelledby="w6mph-h4" hidden>
<p class="w6mph-crumbs"><a href="#" data-go="0">All pieces</a><a href="#" data-go="1">Next piece</a></p>
<div class="w6mph-split">
<img class="w6mph-hero" src="https://images.pexels.com/photos/8063803/pexels-photo-8063803.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="Rows of unglazed white mugs on a dusty studio shelf" width="600" height="400">
<div class="w6mph-txt">
<h2 id="w6mph-h4" tabindex="-1">Bisque mug</h2>
<p class="w6mph-price">£18</p>
<p class="w6mph-desc">Fired once and waiting. Choose the glaze and we fire it again for collection in a week.</p>
<dl class="w6mph-facts">
<div><dt>Size</dt><dd>300 ml</dd></div>
<div><dt>Glaze</dt><dd>Your choice of five</dd></div>
<div><dt>Care</dt><dd>Ready in seven days</dd></div>
</dl>
<button type="button" class="w6mph-btn">Reserve this piece</button>
</div>
</div>
</section>
</div>
</div>
<style>
/* Change these: --w6mph-bg, --w6mph-ink, --w6mph-clay (accent), the 3 / 2 aspect-ratio
(keep card photo and detail photo the same shape so the morph never stretches) and MS in the script. */
.w6mph { --w6mph-bg: #f4e9df; --w6mph-ink: #2e1d14; --w6mph-clay: #a2441f;
height: 640px; display: flex; flex-direction: column; background: var(--w6mph-bg); color: var(--w6mph-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6mph *, .w6mph *::before { box-sizing: border-box; }
.w6mph-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 20px; padding: 20px clamp(16px, 4.5vw, 52px) 14px; }
.w6mph-brand { margin: 0; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; }
.w6mph-brand span { font-weight: 400; color: var(--w6mph-clay); }
.w6mph-note { margin: 0; font-size: .8125rem; color: #6a4b3a; }
.w6mph-stage { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px clamp(16px, 4.5vw, 52px) 28px; }
.w6mph-view[hidden] { display: none; }
.w6mph h2 { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(1.7rem, 3.6vw, 2.5rem); line-height: 1.1; letter-spacing: -.015em; }
.w6mph h2:focus { outline: none; }
.w6mph h2:focus-visible { outline: 2px solid var(--w6mph-clay); outline-offset: 4px; }
.w6mph-intro { margin: 10px 0 0; max-width: 34rem; font-size: 1rem; line-height: 1.55; color: #5a3f30; }
.w6mph-cards { margin: 24px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; }
.w6mph-cards a { display: grid; gap: 2px; color: inherit; text-decoration: none; border-radius: 12px; }
.w6mph-cards a:focus-visible { outline: 2px solid var(--w6mph-clay); outline-offset: 4px; }
.w6mph img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; background: #e3cfbf; }
.w6mph-cards img { margin-bottom: 8px; box-shadow: 0 1px 2px rgba(46,29,20,.12); transition: transform .4s cubic-bezier(.2,.7,.2,1); }
.w6mph-cards a:hover img, .w6mph-cards a:focus-visible img { transform: translateY(-3px); }
.w6mph-cards b { font-size: .9375rem; font-weight: 600; }
.w6mph-cards span { font-size: .875rem; color: #6a4b3a; }
.w6mph-foot { margin: 26px 0 0; padding-top: 14px; border-top: 1px solid #e0c9b8; font-size: .875rem; color: #6a4b3a; }
.w6mph-crumbs { display: flex; justify-content: space-between; gap: 16px; margin: 0 0 10px; }
.w6mph-crumbs a { display: inline-flex; align-items: center; min-height: 40px; color: var(--w6mph-clay); font-size: .9375rem; font-weight: 600; text-underline-offset: 5px; border-radius: 6px; }
.w6mph-crumbs a:first-child::before { content: "←"; margin-right: 8px; }
.w6mph-crumbs a:last-child::after { content: "→"; margin-left: 8px; }
.w6mph-crumbs a:focus-visible, .w6mph-btn:focus-visible { outline: 2px solid var(--w6mph-ink); outline-offset: 3px; }
.w6mph-split { display: grid; gap: 20px; }
.w6mph-hero { box-shadow: 0 18px 40px -24px rgba(46,29,20,.55); }
.w6mph-price { margin: 8px 0 0; font-size: 1.0625rem; color: var(--w6mph-clay); font-weight: 600; }
.w6mph-desc { margin: 12px 0 0; font-size: 1rem; line-height: 1.6; color: #4d3528; max-width: 30rem; }
.w6mph-facts { margin: 16px 0 0; display: grid; gap: 0; border-top: 1px solid #e0c9b8; }
.w6mph-facts div { display: grid; grid-template-columns: 5rem 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid #e0c9b8; font-size: .9rem; }
.w6mph-facts dt { color: #6a4b3a; }
.w6mph-facts dd { margin: 0; }
.w6mph-btn { margin-top: 20px; min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--w6mph-clay); color: #fff;
font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer; }
.w6mph-btn:hover { background: #87381a; }
@media (min-width: 900px) {
.w6mph-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.w6mph-split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; align-items: start; }
}
/* The morph: the clicked photo carries the name w6mph-photo through the swap. The script moves the group with
transform only (same shape before and after, one even scale), so nothing animates width or height.
For separate pages, add @view-transition { navigation: auto; } and give the photo the same name on both pages. */
::view-transition-group(w6mph-photo) { animation: none; transform-origin: 0 0; }
::view-transition-old(w6mph-photo) { animation: none; opacity: 0; }
::view-transition-new(w6mph-photo) { animation: none; }
/* Fallback without view transitions: the text of the new view fades up while the photo is moved by the script. */
@keyframes w6mph-up { from { opacity: 0; transform: translateY(12px); } }
.w6mph[data-fb] .w6mph-view:not([hidden]) .w6mph-txt, .w6mph[data-fb] .w6mph-view:not([hidden]) .w6mph-intro { animation: w6mph-up .45s .1s cubic-bezier(.2,.7,.2,1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6mph-photo), ::view-transition-old(w6mph-photo), ::view-transition-new(w6mph-photo) { animation: none; }
.w6mph .w6mph-txt, .w6mph .w6mph-intro, .w6mph-cards img { animation: none !important; transition: none; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6mph]");
if (!root) return;
//BODY-START
var MS = 520; // length of the photo morph
var DEMO = [[700, 2], [1500, 3], [1500, 0], [2600, 4], [1500, 1], [1500, 0]]; // idle demo: [wait ms, view]; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6mph-stage");
var views = root.querySelectorAll(".w6mph-view"), cards = root.querySelectorAll(".w6mph-cards img");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, step = 0;
// View 0 is the grid, views 1 to 4 are the pieces. Grid to piece (and back) morphs the photo; piece to piece crossfades.
function photo(v, other) { return v ? views[v].querySelector(".w6mph-hero") : cards[other - 1]; }
function go(i, person) {
if (busy || i === cur) return;
var was = cur, from = photo(was, i), to = photo(i, was), a, morph = !was || !i;
var swap = function () {
views[was].hidden = true; views[i].hidden = false; cur = i; stage.scrollTop = 0;
if (person) (i ? views[i].querySelector("h2") : root.querySelector('[data-go="' + was + '"]')).focus({ preventScroll: true });
};
if (rm.matches) return swap();
a = from.getBoundingClientRect();
// Moves the photo from where it was (a) to where it lands (b) with one even scale: transform only.
var move = function (el, pseudo) {
var b = to.getBoundingClientRect(), k = " scale(" + a.width / b.width + ")";
el.animate({ transform: pseudo ? ["translate(" + a.left + "px," + a.top + "px)" + k, "translate(" + b.left + "px," + b.top + "px)"]
: ["translate(" + (a.left - b.left) + "px," + (a.top - b.top) + "px)" + k, "none"] },
{ duration: MS, easing: "cubic-bezier(.2,.75,.2,1)", pseudoElement: pseudo });
};
busy = true;
if (document.startViewTransition) {
if (morph) from.style.viewTransitionName = "w6mph-photo";
var t = document.startViewTransition(function () { from.style.viewTransitionName = ""; swap(); if (morph) to.style.viewTransitionName = "w6mph-photo"; });
if (morph) t.ready.then(function () { move(html, "::view-transition-group(w6mph-photo)"); });
t.finished.finally(function () { to.style.viewTransitionName = ""; busy = false; });
} else {
root.setAttribute("data-fb", ""); swap();
if (morph) { to.style.transformOrigin = "0 0"; move(to); }
setTimeout(function () { busy = false; }, MS);
}
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: open a piece, step to the next one, go back, then repeat with other cards.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go(DEMO[step][1], false);
step = (step + 1) % DEMO.length;
timer = setTimeout(tick, DEMO[step][0]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[step][0]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: The grid and the detail page swap at once, with the photo already in its final place.
Running cost: One captured photo moves by transform for about half a second while the page crossfades; idle cost is zero.
- Change `MS` in the script to make the photo travel faster or slower.
- Keep the `aspect-ratio: 3 / 2` rule on `.w6mph img` identical for cards and the detail photo if you change the shape.
- Swap `--w6mph-clay` and `--w6mph-bg` on `.w6mph` for another shop palette.
Menu Zooms Into Each Course and Back Out
A deep navy restaurant site whose menu page opens each course with a zoom: the list swells and fades as if you leaned in, and the course page settles from slightly small. Returning to the menu plays the zoom in reverse, so depth always tells you whether you went into a detail or came back out.
<div class="w6zom" data-w6zom>
<header class="w6zom-top">
<p class="w6zom-brand">Saltmarsh <em>Kitchen</em></p>
<p class="w6zom-when">Dinner, Wednesday to Saturday</p>
</header>
<div class="w6zom-stage">
<section class="w6zom-view w6zom-menu" aria-labelledby="w6zom-h0">
<p class="w6zom-eye">Set menu, three courses, £46</p>
<h2 id="w6zom-h0" tabindex="-1">Tonight's menu</h2>
<ol class="w6zom-list">
<li><a href="#" data-go="1"><small>Start</small><b>Crab cake, pea purée, crème fraîche</b><span>Open course</span></a></li>
<li><a href="#" data-go="2"><small>Main</small><b>Grilled prawns, carrot purée, pickled shallot</b><span>Open course</span></a></li>
<li><a href="#" data-go="3"><small>Pudding</small><b>Brown butter sponge, mango, dark chocolate</b><span>Open course</span></a></li>
</ol>
<div class="w6zom-foot"><p>Vegetarian set on request. Tables for up to eight, last orders at 9pm.</p><a href="#">Book a table</a></div>
</section>
<section class="w6zom-view" aria-labelledby="w6zom-h1" hidden>
<img src="https://images.pexels.com/photos/23644633/pexels-photo-23644633.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="A small golden crab cake topped with cream on a bed of green purée, on a white plate" width="600" height="400">
<div class="w6zom-txt">
<p class="w6zom-eye">Start</p>
<h2 id="w6zom-h1" tabindex="-1">Crab cake, pea purée, crème fraîche</h2>
<p>Brown and white crab from the harbour boats, bound with a little potato and fried to order in brown butter.</p>
<p class="w6zom-meta">With a glass of Picpoul, £8 · Contains shellfish, egg, milk</p>
<p class="w6zom-nav"><a href="#" data-go="0">Whole menu</a><a href="#" data-go="2">Next course</a></p>
</div>
</section>
<section class="w6zom-view" aria-labelledby="w6zom-h2" hidden>
<img src="https://images.pexels.com/photos/24289165/pexels-photo-24289165.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="A grilled prawn on a mound of grains beside a swirl of orange purée, on a teal plate" width="600" height="400">
<div class="w6zom-txt">
<p class="w6zom-eye">Main</p>
<h2 id="w6zom-h2" tabindex="-1">Grilled prawns, carrot purée, pickled shallot</h2>
<p>Prawns over charcoal with a sweet roast carrot purée, sharp shallot and toasted spelt to soak up the juices.</p>
<p class="w6zom-meta">With a glass of Albariño, £9 · Contains shellfish, gluten</p>
<p class="w6zom-nav"><a href="#" data-go="0">Whole menu</a><a href="#" data-go="3">Next course</a></p>
</div>
</section>
<section class="w6zom-view" aria-labelledby="w6zom-h3" hidden>
<img src="https://images.pexels.com/photos/34520947/pexels-photo-34520947.jpeg?auto=compress&cs=tinysrgb&w=1000" alt="A small sponge pudding with cubes of mango and a stroke of chocolate sauce on a speckled plate" width="600" height="400">
<div class="w6zom-txt">
<p class="w6zom-eye">Pudding</p>
<h2 id="w6zom-h3" tabindex="-1">Brown butter sponge, mango, dark chocolate</h2>
<p>A warm sponge baked in small tins, ripe mango and a spoon of bitter chocolate sauce poured at the table.</p>
<p class="w6zom-meta">With a glass of late harvest Riesling, £7 · Contains gluten, egg, milk</p>
<p class="w6zom-nav"><a href="#" data-go="0">Whole menu</a><a href="#" data-go="1">Back to the start</a></p>
</div>
</section>
</div>
</div>
<style>
/* Change these: --w6zom-navy, --w6zom-cream, --w6zom-brass (accent), and the 1.12 / .9 scales in the
w6zom keyframes (how deep the zoom goes). */
.w6zom { --w6zom-navy: #0f1a2b; --w6zom-cream: #f0e8da; --w6zom-brass: #d6b77f;
height: 600px; display: flex; flex-direction: column; background: var(--w6zom-navy); color: var(--w6zom-cream);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6zom *, .w6zom *::before { box-sizing: border-box; }
.w6zom-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 20px; padding: 20px clamp(16px, 5vw, 56px); border-bottom: 1px solid #24324a; }
.w6zom-brand { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-size: 1.25rem; }
.w6zom-brand em { color: var(--w6zom-brass); }
.w6zom-when { margin: 0; font-size: .8125rem; color: #b6bdc8; }
.w6zom-stage { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.w6zom-view { padding: 28px clamp(16px, 5vw, 56px) 30px; }
.w6zom-view[hidden] { display: none; }
.w6zom-eye { margin: 0; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--w6zom-brass); }
.w6zom h2 { margin: 10px 0 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(1.6rem, 3.4vw, 2.4rem); line-height: 1.12; letter-spacing: -.01em; }
.w6zom-menu h2 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.w6zom h2:focus { outline: none; }
.w6zom a:focus-visible, .w6zom h2:focus-visible { outline: 2px solid var(--w6zom-brass); outline-offset: 3px; }
.w6zom-list { margin: 22px 0 0; padding: 0; list-style: none; border-top: 1px solid #2b3a54; }
.w6zom-list a { display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: baseline; gap: 6px 18px; padding: 18px 4px; color: inherit; text-decoration: none; border-bottom: 1px solid #2b3a54; border-radius: 4px; }
.w6zom-list small { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: #aab3c1; }
.w6zom-list b { font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.1rem, 2.2vw, 1.45rem); }
.w6zom-list span { font-size: .8125rem; color: var(--w6zom-brass); }
.w6zom-list span::after { content: " +"; }
.w6zom-list a:hover b { text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--w6zom-brass); }
.w6zom-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-top: 28px; }
.w6zom-foot p { margin: 0; font-size: .9375rem; color: #c3cad5; }
.w6zom-foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 22px; border-radius: 999px; background: var(--w6zom-brass); color: #16202f; font-size: .9375rem; font-weight: 600; text-decoration: none; }
.w6zom-foot a:hover { background: #e3c891; }
.w6zom-view img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; background: #1c2a40; }
.w6zom-txt { margin-top: 20px; }
.w6zom-txt > p:not([class]) { margin: 12px 0 0; max-width: 30rem; font-size: 1rem; line-height: 1.6; color: #d3cbbd; }
.w6zom-meta { margin: 14px 0 0; font-size: .8125rem; color: #aab3c1; }
.w6zom-nav { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 18px 0 0; }
.w6zom-nav a { display: inline-flex; align-items: center; min-height: 40px; color: var(--w6zom-brass); font-size: .9375rem; text-underline-offset: 5px; border-radius: 4px; }
@media (max-width: 560px) { .w6zom-list a { grid-template-columns: 1fr; } .w6zom-list span { display: none; } }
@media (min-width: 860px) {
.w6zom-view:not(.w6zom-menu) { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 44px; align-items: center; padding-top: 40px; }
.w6zom-view[hidden] { display: none; }
.w6zom-txt { margin-top: 0; }
}
/* Opening a course zooms into the page (old grows and fades, new settles from slightly small);
going back to the menu zooms out. Only the stage carries a name, and only during the change.
Separate pages: add @view-transition { navigation: auto; } and name the main element on each page. */
::view-transition-group(w6zom-stage) { animation: none; overflow: clip; }
::view-transition-old(w6zom-stage), ::view-transition-new(w6zom-stage) { mix-blend-mode: normal; }
::view-transition-old(w6zom-stage) { animation: w6zom-past .3s cubic-bezier(.3, 0, .3, 1) both; }
::view-transition-new(w6zom-stage) { animation: w6zom-near .55s .08s cubic-bezier(.2, .8, .2, 1) both; }
:root[data-w6zom-dir="out"]::view-transition-old(w6zom-stage) { animation-name: w6zom-away; }
:root[data-w6zom-dir="out"]::view-transition-new(w6zom-stage) { animation-name: w6zom-back; }
@keyframes w6zom-past { to { opacity: 0; transform: scale(1.12); } }
@keyframes w6zom-near { from { opacity: 0; transform: scale(.9); } }
@keyframes w6zom-away { to { opacity: 0; transform: scale(.9); } }
@keyframes w6zom-back { from { opacity: 0; transform: scale(1.12); } }
.w6zom[data-fb="in"] .w6zom-view:not([hidden]) { animation: w6zom-near .45s cubic-bezier(.2, .8, .2, 1) both; }
.w6zom[data-fb="out"] .w6zom-view:not([hidden]) { animation: w6zom-back .45s cubic-bezier(.2, .8, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6zom-stage), ::view-transition-old(w6zom-stage), ::view-transition-new(w6zom-stage) { animation: none; }
.w6zom .w6zom-view { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6zom]");
if (!root) return;
//BODY-START
var DEMO = [[700, 1], [1700, 2], [1700, 0], [2600, 3], [1700, 0]]; // idle demo: [wait ms, view]; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6zom-stage");
var views = root.querySelectorAll(".w6zom-view");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, step = 0;
// View 0 is the menu. Going to it zooms out; going to any course zooms in.
function go(i, person) {
if (i === cur || busy) return;
var dir = i ? "in" : "out", was = cur;
var swap = function () {
views[was].hidden = true; views[i].hidden = false; cur = i; stage.scrollTop = 0;
if (person) (i ? views[i].querySelector("h2") : root.querySelector('.w6zom-list [data-go="' + was + '"]')).focus({ preventScroll: true });
};
if (rm.matches) return swap();
if (document.startViewTransition) {
busy = true;
stage.style.viewTransitionName = "w6zom-stage";
html.setAttribute("data-w6zom-dir", dir);
document.startViewTransition(swap).finished.finally(function () {
stage.style.viewTransitionName = ""; html.removeAttribute("data-w6zom-dir"); busy = false;
});
} else { root.setAttribute("data-fb", dir); swap(); }
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: opens courses and returns to the menu while the piece is on screen and untouched.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go(DEMO[step][1], false);
step = (step + 1) % DEMO.length;
timer = setTimeout(tick, DEMO[step][0]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[step][0]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: Courses and the menu replace each other instantly with no scaling or fading.
Running cost: Two snapshots of the page area scale and fade for about half a second; the menu costs nothing while it sits still.
- Change the `1.12` and `.9` scales in the four `w6zom` keyframes for a deeper or flatter zoom.
- Swap `--w6zom-navy`, `--w6zom-cream` and `--w6zom-brass` on `.w6zom` to match another dining room.
- Edit the `DEMO` list in the script to change or stop the automatic tour.
New Page Slides Up Over the Old One
An architecture practice site in graphite where pages behave like a stack of sheets. A later page slides up from the bottom and covers the current one, which sinks back and darkens; an earlier page is uncovered as the top sheet drops away. It suits portfolio sites with a few large, photo-led pages.
<div class="w6stk" data-w6stk>
<header class="w6stk-top">
<p class="w6stk-brand">Marrick Lowe <span>Architects</span></p>
<nav aria-label="Practice pages">
<ul class="w6stk-nav">
<li><a href="#" data-go="0" data-nav aria-current="page"><small>01</small>Work</a></li>
<li><a href="#" data-go="1" data-nav><small>02</small>Studio</a></li>
<li><a href="#" data-go="2" data-nav><small>03</small>Contact</a></li>
</ul>
</nav>
</header>
<div class="w6stk-stage">
<section class="w6stk-view" aria-labelledby="w6stk-h0">
<div class="w6stk-pic"><img src="https://images.pexels.com/photos/6342356/pexels-photo-6342356.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A white house with dark window frames on a rocky, planted hillside" width="900" height="600"></div>
<div class="w6stk-txt">
<p class="w6stk-eye">Selected work</p>
<h2 id="w6stk-h0" tabindex="-1">Houses that sit low in the land</h2>
<p>A family house on a terraced slope, built around the old retaining walls rather than through them, with every room a step lower than the last.</p>
<dl class="w6stk-facts"><div><dt>Year</dt><dd>2025</dd></div><div><dt>Area</dt><dd>180 m²</dd></div><div><dt>Built in</dt><dd>Stone, lime, oak</dd></div></dl>
<a class="w6stk-more" href="#" data-go="1">How we work</a>
</div>
</section>
<section class="w6stk-view" aria-labelledby="w6stk-h1" hidden>
<div class="w6stk-pic"><img src="https://images.pexels.com/photos/12780906/pexels-photo-12780906.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="A concrete hallway with lift doors in red frames and long bands of sunlight across the floor" width="900" height="600"></div>
<div class="w6stk-txt">
<p class="w6stk-eye">The studio</p>
<h2 id="w6stk-h1" tabindex="-1">Eleven people in a former print hall</h2>
<p>Every project starts with a day on site and a model on the long table, and the same two partners stay with it until the keys are handed over.</p>
<dl class="w6stk-facts"><div><dt>Founded</dt><dd>2011</dd></div><div><dt>Partners</dt><dd>Ana Marrick, Joel Lowe</dd></div><div><dt>Projects</dt><dd>Homes, schools, workshops</dd></div></dl>
<a class="w6stk-more" href="#" data-go="2">Start a project</a>
</div>
</section>
<section class="w6stk-view" aria-labelledby="w6stk-h2" hidden>
<div class="w6stk-pic"><img src="https://images.pexels.com/photos/27953061/pexels-photo-27953061.jpeg?auto=compress&cs=tinysrgb&w=1200" alt="Two plain white gabled houses against a clear blue sky" width="900" height="600"></div>
<div class="w6stk-txt">
<p class="w6stk-eye">Contact</p>
<h2 id="w6stk-h2" tabindex="-1">Tell us about the site first</h2>
<p>Send a few photos, the address and roughly what you hope for. We reply within a week, including when we are not the right fit.</p>
<dl class="w6stk-facts"><div><dt>Phone</dt><dd>020 7946 0321</dd></div><div><dt>Studio</dt><dd>Unit 4, Coldharbour Yard</dd></div><div><dt>Hours</dt><dd>Mon to Fri, 9 to 6</dd></div></dl>
<a class="w6stk-more" href="#" data-go="0">Back to the work</a>
</div>
</section>
</div>
</div>
<style>
/* Change these: --w6stk-bg, --w6stk-ink, --w6stk-stone (accent), the .55s / .6s durations and the .92 scale
in the w6stk keyframes (how far the page underneath sinks back). */
.w6stk { --w6stk-bg: #1c1d1f; --w6stk-ink: #ece8e2; --w6stk-stone: #cdbca4;
height: 620px; display: flex; flex-direction: column; background: var(--w6stk-bg); color: var(--w6stk-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6stk *, .w6stk *::before { box-sizing: border-box; }
.w6stk-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; padding: 16px clamp(16px, 4vw, 44px); }
.w6stk-brand { margin: 0; font-size: .9375rem; font-weight: 600; letter-spacing: .02em; }
.w6stk-brand span { font-weight: 400; color: #a9a39b; }
.w6stk-nav { display: flex; gap: 4px; margin: 0 -10px; padding: 0; list-style: none; }
.w6stk-nav a { display: inline-flex; align-items: baseline; gap: 6px; min-height: 40px; padding: 10px; color: #b9b3ab; font-size: .9375rem; text-decoration: none; border-radius: 6px; }
.w6stk-nav small { font-size: .6875rem; color: #8d877f; font-variant-numeric: tabular-nums; }
.w6stk-nav a:hover, .w6stk-nav a[aria-current="page"] { color: var(--w6stk-ink); }
.w6stk-nav a[aria-current="page"] small { color: var(--w6stk-stone); }
.w6stk a:focus-visible, .w6stk h2:focus-visible { outline: 2px solid var(--w6stk-stone); outline-offset: 3px; }
.w6stk h2:focus { outline: none; }
.w6stk-stage { position: relative; flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.w6stk-view { min-height: 100%; display: grid; background: #26272a; border-top: 1px solid #3a3b3f; }
.w6stk-view[hidden] { display: none; }
.w6stk-pic { overflow: hidden; aspect-ratio: 16 / 9; background: #333; }
.w6stk-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.w6stk-txt { padding: 24px clamp(16px, 4vw, 44px) 28px; }
.w6stk-eye { margin: 0; font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--w6stk-stone); }
.w6stk h2 { margin: 10px 0 0; font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 500; line-height: 1.1; letter-spacing: -.02em; max-width: 16ch; }
.w6stk-txt > p:not(.w6stk-eye) { margin: 14px 0 0; max-width: 32rem; font-size: 1rem; line-height: 1.6; color: #c9c4bc; }
.w6stk-facts { margin: 20px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border-top: 1px solid #3f4044; padding-top: 14px; }
.w6stk-facts dt { font-size: .75rem; color: #9d978f; }
.w6stk-facts dd { margin: 4px 0 0; font-size: .875rem; }
.w6stk-more { display: inline-flex; align-items: center; min-height: 44px; margin-top: 18px; padding: 0 18px; border: 1px solid #5a5b60; border-radius: 999px;
color: var(--w6stk-ink); font-size: .875rem; text-decoration: none; }
.w6stk-more:hover { border-color: var(--w6stk-stone); }
.w6stk-more::after { content: "→"; margin-left: 10px; color: var(--w6stk-stone); }
@media (min-width: 860px) {
.w6stk-view { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.w6stk-pic { aspect-ratio: auto; height: 100%; }
.w6stk-txt { align-self: center; padding: 32px 44px; }
}
@media (max-width: 480px) { .w6stk-facts { grid-template-columns: 1fr 1fr; } }
/* Forward: the new page slides up over the old one, which sinks back and darkens. Back: the top page slides away
downwards and the one underneath comes forward. Only the stage is named, and only during the change.
Separate pages: add @view-transition { navigation: auto; } and name the main element on every page. */
::view-transition-group(w6stk-stage) { animation: none; overflow: clip; }
::view-transition-old(w6stk-stage), ::view-transition-new(w6stk-stage) { mix-blend-mode: normal; }
::view-transition-old(w6stk-stage) { animation: w6stk-sink .6s cubic-bezier(.3, 0, .2, 1) both; }
::view-transition-new(w6stk-stage) { animation: w6stk-rise .6s cubic-bezier(.2, .8, .2, 1) both; }
:root[data-w6stk-dir="b"]::view-transition-old(w6stk-stage) { z-index: 1; animation: w6stk-drop .55s cubic-bezier(.5, 0, .7, .4) both; }
:root[data-w6stk-dir="b"]::view-transition-new(w6stk-stage) { animation: w6stk-lift .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes w6stk-sink { to { transform: scale(.92); opacity: .25; } }
@keyframes w6stk-rise { from { transform: translateY(100%); } }
@keyframes w6stk-drop { to { transform: translateY(100%); } }
@keyframes w6stk-lift { from { transform: scale(.92); opacity: .25; } }
/* Fallback without view transitions: the new page rises a little and fades in. */
@keyframes w6stk-in { from { transform: translateY(40px); opacity: 0; } }
.w6stk[data-fb] .w6stk-view:not([hidden]) { animation: w6stk-in .5s cubic-bezier(.2, .8, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6stk-stage), ::view-transition-old(w6stk-stage), ::view-transition-new(w6stk-stage) { animation: none; }
.w6stk .w6stk-view { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6stk]");
if (!root) return;
//BODY-START
var DEMO = [700, 1700, 3200]; // idle demo: ms before each automatic page change; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6stk-stage");
var views = root.querySelectorAll(".w6stk-view"), navs = root.querySelectorAll("[data-nav]");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
function show(i) {
views.forEach(function (v, k) { v.hidden = k !== i; });
navs.forEach(function (a, k) { if (k === i) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current"); });
cur = i; stage.scrollTop = 0;
}
// A later page lands on top of the stack; an earlier one is uncovered from underneath.
function go(i, person) {
if (i === cur || busy) return;
var dir = i > cur ? "f" : "b";
var swap = function () { show(i); if (person) views[i].querySelector("h2").focus({ preventScroll: true }); };
if (rm.matches) return swap();
if (document.startViewTransition) {
busy = true;
stage.style.viewTransitionName = "w6stk-stage";
html.setAttribute("data-w6stk-dir", dir);
document.startViewTransition(swap).finished.finally(function () {
stage.style.viewTransitionName = ""; html.removeAttribute("data-w6stk-dir"); busy = false;
});
} else { root.setAttribute("data-fb", ""); swap(); }
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: changes page now and then while the piece is on screen and nobody has used it.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go((cur + 1) % views.length, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: The new page appears straight away in place of the old one, with no sliding or dimming.
Running cost: Two snapshots of the content area move for about six tenths of a second; nothing runs while a page is open.
- Change the `.92` scale and `.25` opacity in `w6stk-sink` and `w6stk-lift` to make the page underneath sink further or stay brighter.
- Edit `--w6stk-bg`, `--w6stk-ink` and `--w6stk-stone` on `.w6stk` for another palette.
- Lengthen the `.6s` on `::view-transition-new(w6stk-stage)` for a slower slide.
Page Tabs With Gliding Underline and Rising Content
A plant nursery site with four pages in a tab-style menu. Choosing a page makes the green underline glide and stretch from the old link to the new one, while the old content dips out and the new content rises into place. It is a light, quick change for sections that people flick between often.
<div class="w6tab" data-w6tab>
<header class="w6tab-top">
<p class="w6tab-brand"><svg viewBox="0 0 24 24" width="22" height="22" aria-hidden="true"><path d="M12 21V9m0 0C12 5 9 3 5 3c0 4 3 6 7 6Zm0 4c0-3 3-5 7-5 0 3-3 5-7 5Z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>Fernhollow Nursery</p>
<nav aria-label="Nursery pages">
<ul class="w6tab-nav">
<li><a href="#" data-go="0" aria-current="page">Plants<span class="w6tab-bar" aria-hidden="true"></span></a></li>
<li><a href="#" data-go="1">Workshops<span class="w6tab-bar" aria-hidden="true"></span></a></li>
<li><a href="#" data-go="2">Delivery<span class="w6tab-bar" aria-hidden="true"></span></a></li>
<li><a href="#" data-go="3">Visit<span class="w6tab-bar" aria-hidden="true"></span></a></li>
</ul>
</nav>
</header>
<div class="w6tab-panel">
<section class="w6tab-view" aria-labelledby="w6tab-h0">
<div class="w6tab-intro">
<h2 id="w6tab-h0" tabindex="-1">Grown here, in peat-free compost</h2>
<p>Everything on the benches spent at least one winter outside in our valley, so it is ready for yours.</p>
</div>
<ul class="w6tab-tiles">
<li><b>Hardy ferns</b><span>2 litre pots, £9</span></li>
<li><b>Woodland perennials</b><span>9 cm pots, £5.50</span></li>
<li><b>Native hedging</b><span>Bare root, from £1.80</span></li>
<li><b>Fruit trees</b><span>Two year old, £38</span></li>
</ul>
</section>
<section class="w6tab-view" aria-labelledby="w6tab-h1" hidden>
<div class="w6tab-intro">
<h2 id="w6tab-h1" tabindex="-1">Saturday mornings in the potting shed</h2>
<p>Small groups of eight, tea included, and you take home whatever you planted.</p>
</div>
<ul class="w6tab-tiles">
<li><b>Winter pruning</b><span>8 Nov, 10am, £25</span></li>
<li><b>Planting a hedge</b><span>22 Nov, 10am, £25</span></li>
<li><b>Wreaths from the woods</b><span>6 Dec, 10am, £32</span></li>
<li><b>Seed sowing basics</b><span>14 Feb, 10am, £20</span></li>
</ul>
</section>
<section class="w6tab-view" aria-labelledby="w6tab-h2" hidden>
<div class="w6tab-intro">
<h2 id="w6tab-h2" tabindex="-1">Big plants, brought by our own van</h2>
<p>We deliver on Tuesdays and Fridays and carry everything round to the back garden.</p>
</div>
<ul class="w6tab-tiles">
<li><b>Within 5 miles</b><span>£6 per drop</span></li>
<li><b>5 to 15 miles</b><span>£12</span></li>
<li><b>Trees over 2 m</b><span>Two people, £20</span></li>
<li><b>Planting service</b><span>Quoted on the day</span></li>
</ul>
</section>
<section class="w6tab-view" aria-labelledby="w6tab-h3" hidden>
<div class="w6tab-intro">
<h2 id="w6tab-h3" tabindex="-1">Open every day but Christmas</h2>
<p>Down the lane past the church, with parking in the paddock and a dog bowl by the gate.</p>
</div>
<ul class="w6tab-tiles">
<li><b>Monday to Saturday</b><span>9am to 5pm</span></li>
<li><b>Sunday</b><span>10am to 4pm</span></li>
<li><b>Address</b><span>Mill Lane, Ashcombe</span></li>
<li><b>Phone</b><span>01632 960 552</span></li>
</ul>
</section>
</div>
</div>
<style>
/* Change these: --w6tab-bg, --w6tab-ink, --w6tab-moss (accent and underline), MS in the script (underline glide)
and the .4s on the w6tab-rise keyframe (how long new content takes to settle). */
.w6tab { --w6tab-bg: #edf1e7; --w6tab-ink: #1c2f25; --w6tab-moss: #2e5e45;
height: 500px; display: flex; flex-direction: column; background: var(--w6tab-bg); color: var(--w6tab-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6tab *, .w6tab *::before { box-sizing: border-box; }
.w6tab-top { padding: 22px clamp(16px, 5vw, 56px) 0; border-bottom: 1px solid #cdd7c6; }
.w6tab-brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.0625rem; font-weight: 600; color: var(--w6tab-moss); }
.w6tab-nav { display: flex; gap: clamp(14px, 3.5vw, 36px); margin: 14px 0 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.w6tab-nav a { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; color: #3f5649; font-size: .9375rem; font-weight: 500; text-decoration: none; white-space: nowrap; border-radius: 4px; }
.w6tab-nav a:hover, .w6tab-nav a[aria-current="page"] { color: var(--w6tab-ink); }
.w6tab-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--w6tab-moss); opacity: 0; }
.w6tab-nav a[aria-current="page"] .w6tab-bar { opacity: 1; }
.w6tab a:focus-visible, .w6tab h2:focus-visible { outline: 2px solid var(--w6tab-moss); outline-offset: 3px; }
.w6tab h2:focus { outline: none; }
.w6tab-panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.w6tab-view { display: grid; gap: 24px; padding: 30px clamp(16px, 5vw, 56px) 28px; }
.w6tab-view[hidden] { display: none; }
.w6tab h2 { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(1.7rem, 3.6vw, 2.6rem); line-height: 1.1; letter-spacing: -.015em; max-width: 17ch; }
.w6tab-intro p { margin: 14px 0 0; max-width: 30rem; font-size: 1.0625rem; line-height: 1.6; color: #3c5246; }
.w6tab-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.w6tab-tiles li { display: grid; gap: 6px; align-content: start; min-height: 96px; padding: 16px; border-radius: 14px; background: #fbfcf8; box-shadow: 0 1px 2px rgba(28,47,37,.08), 0 8px 20px -16px rgba(28,47,37,.35); }
.w6tab-tiles b { font-size: .9375rem; font-weight: 600; }
.w6tab-tiles span { font-size: .875rem; color: #4a5f53; }
@media (min-width: 880px) { .w6tab-view { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 48px; align-items: start; padding-top: 44px; } }
/* Two named parts: the active underline glides to the new link (moved by the script with transform),
and the panel content drops out while the new content rises in. Names exist only during the change.
Multi-page sites: add @view-transition { navigation: auto; } and the same names on every page. */
::view-transition-group(w6tab-bar) { animation: none; transform-origin: 0 0; }
::view-transition-old(w6tab-bar) { animation: none; opacity: 0; }
::view-transition-new(w6tab-bar) { animation: none; }
::view-transition-group(w6tab-panel) { animation: none; overflow: clip; }
::view-transition-old(w6tab-panel), ::view-transition-new(w6tab-panel) { mix-blend-mode: normal; }
::view-transition-old(w6tab-panel) { animation: w6tab-drop .16s cubic-bezier(0, 0, .2, 1) both; }
::view-transition-new(w6tab-panel) { animation: w6tab-rise .4s .12s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes w6tab-drop { to { opacity: 0; transform: translateY(-8px); } }
@keyframes w6tab-rise { from { opacity: 0; transform: translateY(16px); } }
.w6tab[data-fb] .w6tab-view:not([hidden]) { animation: w6tab-rise .4s cubic-bezier(.2, .8, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6tab-bar), ::view-transition-group(w6tab-panel), ::view-transition-old(w6tab-panel), ::view-transition-new(w6tab-panel) { animation: none; }
.w6tab .w6tab-view { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6tab]");
if (!root) return;
//BODY-START
var MS = 420; // underline glide in ms
var DEMO = [700, 1600, 2800]; // idle demo: ms before each automatic tab change; [] turns it off
var html = document.documentElement, panel = root.querySelector(".w6tab-panel");
var views = root.querySelectorAll(".w6tab-view"), links = root.querySelectorAll(".w6tab-nav a"), bars = root.querySelectorAll(".w6tab-bar");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
function show(i) {
views.forEach(function (v, k) { v.hidden = k !== i; });
links.forEach(function (a, k) { if (k === i) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current"); });
cur = i; panel.scrollTop = 0;
}
// Slides and stretches the underline from rect a to rect b with transform only.
function glide(el, a, b, pseudo) {
var s = " scale(" + a.width / b.width + ",1)";
el.animate({ transform: pseudo ? ["translate(" + a.left + "px," + a.top + "px)" + s, "translate(" + b.left + "px," + b.top + "px)"]
: ["translate(" + (a.left - b.left) + "px,0)" + s, "none"] }, { duration: MS, easing: "cubic-bezier(.3,.8,.2,1)", pseudoElement: pseudo });
}
function go(i, person) {
if (i === cur || busy) return;
var from = bars[cur], to = bars[i], a = from.getBoundingClientRect();
var swap = function () { show(i); if (person) views[i].querySelector("h2").focus({ preventScroll: true }); };
if (rm.matches) return swap();
busy = true;
if (document.startViewTransition) {
from.style.viewTransitionName = "w6tab-bar"; panel.style.viewTransitionName = "w6tab-panel";
var t = document.startViewTransition(function () { from.style.viewTransitionName = ""; swap(); to.style.viewTransitionName = "w6tab-bar"; });
t.ready.then(function () { glide(html, a, to.getBoundingClientRect(), "::view-transition-group(w6tab-bar)"); });
t.finished.finally(function () { to.style.viewTransitionName = panel.style.viewTransitionName = ""; busy = false; });
} else {
root.setAttribute("data-fb", ""); swap(); to.style.transformOrigin = "0 0";
glide(to, a, to.getBoundingClientRect());
setTimeout(function () { busy = false; }, MS);
}
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: steps through the tabs while the piece is on screen and nobody has used it.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go((cur + 1) % views.length, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: The underline jumps to the new link and the new content appears without any movement.
Running cost: One thin bar and one content snapshot move by transform for under half a second; there is no work between clicks.
- Change `MS` in the script for a slower or quicker underline glide.
- Edit the `16px` in `w6tab-rise` and the `-8px` in `w6tab-drop` to change how far the content moves.
- Recolour the underline, heading accents and focus ring with `--w6tab-moss`.
Sibling Pages Slide in Reading Direction
A small bookshop site with four pages that sit side by side. Going to a later page slides the old one out to the left while the new one arrives from the right, and going back reverses it, so the motion always agrees with the order in the menu. Only the content area moves; the header and menu stay still.
<div class="w6sld" data-w6sld>
<header class="w6sld-top">
<p class="w6sld-brand">Hollins <span>&</span> Vale <small>Booksellers</small></p>
<nav aria-label="Bookshop pages">
<ul class="w6sld-nav">
<li><a href="#" data-go="0" data-nav aria-current="page">Shop</a></li>
<li><a href="#" data-go="1" data-nav>Events</a></li>
<li><a href="#" data-go="2" data-nav>Visit</a></li>
<li><a href="#" data-go="3" data-nav>Orders</a></li>
</ul>
</nav>
</header>
<div class="w6sld-stage">
<section class="w6sld-view" aria-labelledby="w6sld-h0">
<p class="w6sld-num" aria-hidden="true">01</p>
<div class="w6sld-body">
<p class="w6sld-eye">The shop</p>
<h2 id="w6sld-h0" tabindex="-1">Two rooms of books above the old print works</h2>
<p class="w6sld-lead">New fiction, poetry and local history at the front, and a back room of secondhand finds sorted by whoever had the afternoon free.</p>
<ul class="w6sld-list">
<li><b>The Salt Year</b><span>Ines Harrow, paperback</span></li>
<li><b>Field Notes from a Flooded Valley</b><span>Tom Ashdown, hardback</span></li>
<li><b>Small Hours</b><span>Mira Coyle, poems</span></li>
</ul>
</div>
<p class="w6sld-pager"><a href="#" data-go="1">Next: Events</a></p>
</section>
<section class="w6sld-view" aria-labelledby="w6sld-h1" hidden>
<p class="w6sld-num" aria-hidden="true">02</p>
<div class="w6sld-body">
<p class="w6sld-eye">Events</p>
<h2 id="w6sld-h1" tabindex="-1">Readings in the back room</h2>
<p class="w6sld-lead">Thirty folding chairs, a kettle and a writer. Seats are free, but tell us you are coming so we set out enough cups.</p>
<ul class="w6sld-list">
<li><b>Thu 23 Oct, 7pm</b><span>Poetry night with three local poets</span></li>
<li><b>Sat 1 Nov, 11am</b><span>Story hour for under sevens</span></li>
<li><b>Wed 12 Nov, 7pm</b><span>Tom Ashdown on rivers and memory</span></li>
</ul>
</div>
<p class="w6sld-pager"><a href="#" data-go="0">Previous: Shop</a><a href="#" data-go="2">Next: Visit</a></p>
</section>
<section class="w6sld-view" aria-labelledby="w6sld-h2" hidden>
<p class="w6sld-num" aria-hidden="true">03</p>
<div class="w6sld-body">
<p class="w6sld-eye">Visit</p>
<h2 id="w6sld-h2" tabindex="-1">Up the stairs at 14 Tanner Row</h2>
<p class="w6sld-lead">The door is the green one next to the bakery. There is a ramp at the side entrance and a bench by the poetry shelves.</p>
<ul class="w6sld-list">
<li><b>Tuesday to Friday</b><span>10am to 6pm</span></li>
<li><b>Saturday</b><span>9am to 5pm</span></li>
<li><b>Sunday and Monday</b><span>Closed, except for readings</span></li>
</ul>
</div>
<p class="w6sld-pager"><a href="#" data-go="1">Previous: Events</a><a href="#" data-go="3">Next: Orders</a></p>
</section>
<section class="w6sld-view" aria-labelledby="w6sld-h3" hidden>
<p class="w6sld-num" aria-hidden="true">04</p>
<div class="w6sld-body">
<p class="w6sld-eye">Orders</p>
<h2 id="w6sld-h3" tabindex="-1">Ask for any book still in print</h2>
<p class="w6sld-lead">Leave the title at the counter or by phone and we will call when it lands, usually within three working days.</p>
<ul class="w6sld-list">
<li><b>Phone</b><span>01632 960 418</span></li>
<li><b>Counter</b><span>Any opening hour</span></li>
<li><b>Collection</b><span>Kept for two weeks under your name</span></li>
</ul>
</div>
<p class="w6sld-pager"><a href="#" data-go="2">Previous: Visit</a></p>
</section>
</div>
</div>
<style>
/* Change these: --w6sld-paper (background), --w6sld-ink (text), --w6sld-red (accent),
the 22% and 12% in the w6sld keyframes (how far pages slide) and the .26s and .5s durations. */
.w6sld { --w6sld-paper: #f4eee3; --w6sld-ink: #2b211a; --w6sld-red: #8c2f24;
height: 600px; display: flex; flex-direction: column; box-sizing: border-box; background: var(--w6sld-paper); color: var(--w6sld-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6sld *, .w6sld *::before { box-sizing: border-box; }
.w6sld-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding: 20px clamp(16px, 5vw, 56px);
border-bottom: 1px solid #ddd0bd; }
.w6sld-brand { margin: 0; font-family: Georgia, "Iowan Old Style", serif; font-size: 1.25rem; letter-spacing: -.01em; }
.w6sld-brand span { font-style: italic; color: var(--w6sld-red); }
.w6sld-brand small { margin-left: 6px; font-family: ui-sans-serif, system-ui, sans-serif; font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: #6b5a4b; }
.w6sld-nav { display: flex; gap: 2px; margin: 0 -10px; padding: 0; list-style: none; }
.w6sld a { color: inherit; }
.w6sld-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; font-size: .9375rem; text-decoration: none; border-radius: 6px;
text-underline-offset: 6px; }
.w6sld-nav a:hover { text-decoration: underline; }
.w6sld-nav a[aria-current="page"] { color: var(--w6sld-red); text-decoration: underline; text-decoration-thickness: 2px; }
.w6sld a:focus-visible, .w6sld h2:focus-visible { outline: 2px solid var(--w6sld-red); outline-offset: 3px; }
.w6sld h2:focus { outline: none; }
.w6sld-stage { position: relative; flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.w6sld-view { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 18px;
padding: 28px clamp(16px, 5vw, 56px) 24px; }
.w6sld-view[hidden] { display: none; }
.w6sld-num { margin: 0; font-family: Georgia, serif; font-style: italic; font-size: 2.5rem; line-height: 1; color: var(--w6sld-red); }
.w6sld-eye { margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: #6b5a4b; }
.w6sld h2 { margin: 8px 0 0; max-width: 18ch; font-family: Georgia, "Iowan Old Style", serif; font-weight: 400; font-size: clamp(1.75rem, 4.2vw, 2.75rem);
line-height: 1.08; letter-spacing: -.02em; }
.w6sld-lead { margin: 14px 0 0; max-width: 36rem; font-size: 1.0625rem; line-height: 1.6; color: #4a3b2f; }
.w6sld-list { margin: 20px 0 0; padding: 0; list-style: none; max-width: 36rem; border-top: 1px solid #ddd0bd; }
.w6sld-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 11px 0; border-bottom: 1px solid #ddd0bd; font-size: .9375rem; }
.w6sld-list b { font-weight: 600; }
.w6sld-list span { color: #5c4b3d; }
@media (max-width: 520px) { .w6sld-list li { flex-direction: column; } }
.w6sld-pager { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 4px 0 0; font-size: .9375rem; }
.w6sld-pager a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; text-underline-offset: 5px; }
.w6sld-pager a:last-child:not(:first-child) { margin-left: auto; }
@media (min-width: 860px) {
.w6sld-view { grid-template-columns: minmax(0, 1fr) 15rem; column-gap: 48px; padding-top: 40px; }
.w6sld-num { grid-column: 2; grid-row: 1; justify-self: end; font-size: 9rem; letter-spacing: -.04em; opacity: .9; }
.w6sld-body { grid-column: 1; grid-row: 1; }
.w6sld-pager { grid-column: 1 / -1; }
}
/* The slide. Only the stage is named, and only while a transition runs, so the header stays put.
For a multi-page site add @view-transition { navigation: auto; } and give the main element the name on every page. */
::view-transition-group(w6sld-stage) { animation: none; overflow: clip; }
::view-transition-old(w6sld-stage), ::view-transition-new(w6sld-stage) { mix-blend-mode: normal; }
/* The old page leaves quickly, the new one follows a beat later, so the two never sit on top of each other for long. */
::view-transition-old(w6sld-stage) { animation: w6sld-out .26s cubic-bezier(.2, 0, .2, 1) both; }
::view-transition-new(w6sld-stage) { animation: w6sld-in .5s .1s cubic-bezier(.2, .7, .2, 1) both; }
:root[data-w6sld-dir="b"]::view-transition-old(w6sld-stage) { animation-name: w6sld-out-b; }
:root[data-w6sld-dir="b"]::view-transition-new(w6sld-stage) { animation-name: w6sld-in-b; }
@keyframes w6sld-out { to { opacity: 0; transform: translateX(-12%); } }
@keyframes w6sld-in { from { opacity: 0; transform: translateX(22%); } }
@keyframes w6sld-out-b { to { opacity: 0; transform: translateX(12%); } }
@keyframes w6sld-in-b { from { opacity: 0; transform: translateX(-22%); } }
/* Fallback for browsers without view transitions: the new page slides in on its own. */
.w6sld[data-fb="f"] .w6sld-view:not([hidden]) { animation: w6sld-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.w6sld[data-fb="b"] .w6sld-view:not([hidden]) { animation: w6sld-in-b .5s cubic-bezier(.2, .7, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6sld-stage), ::view-transition-old(w6sld-stage), ::view-transition-new(w6sld-stage) { animation: none; }
.w6sld .w6sld-view { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6sld]");
if (!root) return;
//BODY-START
var DEMO = [700, 1700, 3200]; // idle demo: ms before each automatic page turn; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6sld-stage");
var views = root.querySelectorAll(".w6sld-view"), navs = root.querySelectorAll("[data-nav]");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
function show(i) {
views.forEach(function (v, k) { v.hidden = k !== i; });
navs.forEach(function (a, k) { if (k === i) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current"); });
cur = i;
}
// Swap pages; with view transitions the old and new stage are snapshots that slide past each other.
function go(i, person) {
if (i === cur || busy) return;
var dir = i > cur ? "f" : "b";
var swap = function () { show(i); if (person) views[i].querySelector("h2").focus({ preventScroll: true }); };
if (rm.matches) return swap();
if (document.startViewTransition) {
busy = true;
stage.style.viewTransitionName = "w6sld-stage";
html.setAttribute("data-w6sld-dir", dir);
document.startViewTransition(swap).finished.finally(function () {
stage.style.viewTransitionName = ""; html.removeAttribute("data-w6sld-dir"); busy = false;
});
} else { root.setAttribute("data-fb", dir); swap(); }
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: turns a page now and then while the piece is on screen and nobody has used it.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go((cur + 1) % views.length, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: Pages change instantly with no sliding, and focus still moves to the new heading.
Running cost: The browser slides two snapshots of one area for half a second; nothing runs between page changes.
- Change `--w6sld-paper`, `--w6sld-ink` and `--w6sld-red` on `.w6sld` to recolour the page, text and accent.
- Edit the 22% and 12% in the `w6sld-in` and `w6sld-out` keyframes to make pages travel further or less.
- Set `DEMO` to `[]` in the script to stop the automatic page turns in the preview.
Split Columns Slide in Opposite Directions
A joinery workshop site laid out as a split screen, text on one side and a tall photo on the other. Changing page sends the two halves in opposite directions: the words rise out as the new ones rise in, while the photo slides down and the next one drops in from above. Going back flips both.
<div class="w6col" data-w6col>
<header class="w6col-top">
<p class="w6col-brand">Cobble & Finch <span>Joinery</span></p>
<nav aria-label="Joinery pages">
<ul class="w6col-nav">
<li><a href="#" data-go="0" data-nav aria-current="page">Kitchens</a></li>
<li><a href="#" data-go="1" data-nav>Wardrobes</a></li>
<li><a href="#" data-go="2" data-nav>Staircases</a></li>
</ul>
</nav>
</header>
<div class="w6col-stage">
<section class="w6col-view" aria-labelledby="w6col-h0">
<div class="w6col-txt" data-vt="w6col-text">
<p class="w6col-num" aria-hidden="true">01</p>
<h2 id="w6col-h0" tabindex="-1">Kitchens made to the inch</h2>
<p>Painted shaker doors on oak carcasses, worktops cut from a single board where the room allows, and drawers that run on hardwood.</p>
<ul class="w6col-list"><li>Survey and drawings in two weeks</li><li>Fitted by the people who made it</li><li>From £14,000</li></ul>
<a class="w6col-more" href="#" data-go="1">Next: Wardrobes</a>
</div>
<div class="w6col-pic" data-vt="w6col-pic"><img src="https://images.pexels.com/photos/7746657/pexels-photo-7746657.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A kitchen with grey panelled cabinets, a wooden worktop and a steel sink" width="600" height="900"></div>
</section>
<section class="w6col-view" aria-labelledby="w6col-h1" hidden>
<div class="w6col-txt" data-vt="w6col-text">
<p class="w6col-num" aria-hidden="true">02</p>
<h2 id="w6col-h1" tabindex="-1">Wardrobes that use the whole wall</h2>
<p>Built into alcoves, under eaves and around chimney breasts, with the inside planned around what you actually hang and fold.</p>
<ul class="w6col-list"><li>Doors to the ceiling, no gaps to dust</li><li>Lights that come on as a door opens</li><li>From £3,800</li></ul>
<a class="w6col-more" href="#" data-go="2">Next: Staircases</a>
</div>
<div class="w6col-pic" data-vt="w6col-pic"><img src="https://images.pexels.com/photos/31759521/pexels-photo-31759521.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A wall of fitted grey wardrobes with drawers and an open shelf, beside a tall window" width="600" height="900"></div>
</section>
<section class="w6col-view" aria-labelledby="w6col-h2" hidden>
<div class="w6col-txt" data-vt="w6col-text">
<p class="w6col-num" aria-hidden="true">03</p>
<h2 id="w6col-h2" tabindex="-1">Stairs you notice on the way up</h2>
<p>New oak treads over an old frame, or a whole new flight with a handrail turned in the workshop and fitted in one day.</p>
<ul class="w6col-list"><li>Oak, ash or painted pine</li><li>Drawings made in the workshop</li><li>From £6,500</li></ul>
<a class="w6col-more" href="#" data-go="0">Back to Kitchens</a>
</div>
<div class="w6col-pic" data-vt="w6col-pic"><img src="https://images.pexels.com/photos/13005094/pexels-photo-13005094.jpeg?auto=compress&cs=tinysrgb&w=900" alt="A light oak staircase with a curving black iron railing against a white wall" width="600" height="900"></div>
</section>
</div>
</div>
<style>
/* Change these: --w6col-paper, --w6col-ink, --w6col-blue (accent), the 48px and 30% travel in the
w6col keyframes, and the .55s durations. */
.w6col { --w6col-paper: #fafaf9; --w6col-ink: #1e293b; --w6col-blue: #35577a;
height: 620px; display: flex; flex-direction: column; background: var(--w6col-paper); color: var(--w6col-ink);
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.w6col *, .w6col *::before { box-sizing: border-box; }
.w6col-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; padding: 16px clamp(16px, 4.5vw, 52px); border-bottom: 1px solid #e2e8f0; }
.w6col-brand { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.w6col-brand span { font-weight: 400; color: #475569; }
.w6col-nav { display: flex; gap: 2px; margin: 0 -12px; padding: 0; list-style: none; }
.w6col-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 999px; color: #475569; font-size: .9375rem; text-decoration: none; }
.w6col-nav a:hover { color: var(--w6col-ink); }
.w6col-nav a[aria-current="page"] { background: #e8eef5; color: var(--w6col-blue); font-weight: 600; }
.w6col a:focus-visible, .w6col h2:focus-visible { outline: 2px solid var(--w6col-blue); outline-offset: 3px; }
.w6col h2:focus { outline: none; }
.w6col-stage { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.w6col-view { display: flex; flex-direction: column-reverse; }
.w6col-view[hidden] { display: none; }
.w6col-pic { height: 210px; overflow: hidden; background: #e2e8f0; }
.w6col-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.w6col-txt { padding: 22px clamp(16px, 4.5vw, 52px) 28px; background: var(--w6col-paper); }
.w6col-num { margin: 0; font-size: .8125rem; font-weight: 700; letter-spacing: .12em; color: var(--w6col-blue); font-variant-numeric: tabular-nums; }
.w6col h2 { margin: 8px 0 0; font-size: clamp(1.6rem, 3.4vw, 2.5rem); font-weight: 650; line-height: 1.08; letter-spacing: -.025em; max-width: 15ch; }
.w6col-txt > p:not(.w6col-num) { margin: 14px 0 0; max-width: 30rem; font-size: 1rem; line-height: 1.6; color: #475569; }
.w6col-list { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.w6col-list li { display: flex; gap: 10px; font-size: .9375rem; }
.w6col-list li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: .55em; border-radius: 50%; background: var(--w6col-blue); }
.w6col-more { display: inline-flex; align-items: center; min-height: 44px; margin-top: 20px; padding: 0 20px; border-radius: 999px; background: var(--w6col-ink); color: #fff; font-size: .875rem; font-weight: 600; text-decoration: none; }
.w6col-more:hover { background: var(--w6col-blue); }
@media (min-width: 820px) {
.w6col-stage { overflow: hidden; }
.w6col-view { height: 100%; flex-direction: row; }
.w6col-txt { flex: 1.1; align-self: center; padding: 32px 52px; }
.w6col-pic { flex: 1; height: 100%; }
}
/* Two named columns, named only while the page changes. Going forward the text rises and the photo falls,
going back they swap directions; each group clips its own snapshot so nothing spills over the header.
Separate pages: add @view-transition { navigation: auto; } and give both columns these names on every page. */
::view-transition-group(w6col-text), ::view-transition-group(w6col-pic) { animation: none; overflow: clip; }
::view-transition-old(w6col-text), ::view-transition-new(w6col-text), ::view-transition-old(w6col-pic), ::view-transition-new(w6col-pic) { mix-blend-mode: normal; }
::view-transition-old(w6col-text) { animation: w6col-up-out .3s cubic-bezier(.4, 0, .6, 1) both; }
::view-transition-new(w6col-text) { animation: w6col-up-in .55s .1s cubic-bezier(.2, .8, .2, 1) both; }
::view-transition-old(w6col-pic) { animation: w6col-down-out .55s cubic-bezier(.6, 0, .3, 1) both; }
::view-transition-new(w6col-pic) { animation: w6col-down-in .55s cubic-bezier(.6, 0, .3, 1) both; }
:root[data-w6col-dir="b"]::view-transition-old(w6col-text) { animation-name: w6col-down-fade; }
:root[data-w6col-dir="b"]::view-transition-new(w6col-text) { animation-name: w6col-down-text; }
:root[data-w6col-dir="b"]::view-transition-old(w6col-pic) { animation-name: w6col-up-pic; }
:root[data-w6col-dir="b"]::view-transition-new(w6col-pic) { animation-name: w6col-up-from; }
@keyframes w6col-up-out { to { opacity: 0; transform: translateY(-48px); } }
@keyframes w6col-up-in { from { opacity: 0; transform: translateY(48px); } }
@keyframes w6col-down-fade { to { opacity: 0; transform: translateY(48px); } }
@keyframes w6col-down-text { from { opacity: 0; transform: translateY(-48px); } }
@keyframes w6col-down-out { to { transform: translateY(100%); } }
@keyframes w6col-down-in { from { transform: translateY(-100%); } }
@keyframes w6col-up-pic { to { transform: translateY(-100%); } }
@keyframes w6col-up-from { from { transform: translateY(100%); } }
/* Fallback without view transitions: the new columns arrive from opposite sides. */
.w6col[data-fb] .w6col-view:not([hidden]) .w6col-txt { animation: w6col-up-in .5s cubic-bezier(.2, .8, .2, 1) both; }
.w6col[data-fb] .w6col-view:not([hidden]) .w6col-pic img { animation: w6col-settle .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes w6col-settle { from { opacity: 0; transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(w6col-text), ::view-transition-group(w6col-pic), ::view-transition-old(w6col-text), ::view-transition-new(w6col-text),
::view-transition-old(w6col-pic), ::view-transition-new(w6col-pic) { animation: none; }
.w6col .w6col-txt, .w6col .w6col-pic img { animation: none !important; }
}
</style>
<script>
(function () {
var root = document.querySelector("[data-w6col]");
if (!root) return;
//BODY-START
var DEMO = [700, 1700, 3000]; // idle demo: ms before each automatic page change; [] turns it off
var html = document.documentElement, stage = root.querySelector(".w6col-stage");
var views = root.querySelectorAll(".w6col-view"), navs = root.querySelectorAll("[data-nav]");
var rm = matchMedia("(prefers-reduced-motion: reduce)");
var cur = 0, busy = false, auto = DEMO.length > 0, seen = false, timer = 0, turns = 0;
// Gives (or takes away) each column of a view its view-transition-name from data-vt.
function tag(v, on) { v.querySelectorAll("[data-vt]").forEach(function (n) { n.style.viewTransitionName = on ? n.getAttribute("data-vt") : ""; }); }
function go(i, person) {
if (i === cur || busy) return;
var dir = i > cur ? "f" : "b", was = views[cur];
var swap = function () {
tag(was, false); was.hidden = true; views[i].hidden = false; tag(views[i], !rm.matches && !!document.startViewTransition);
navs.forEach(function (a, k) { if (k === i) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current"); });
cur = i; stage.scrollTop = 0;
if (person) views[i].querySelector("h2").focus({ preventScroll: true });
};
if (rm.matches) return swap();
if (document.startViewTransition) {
busy = true; tag(was, true);
html.setAttribute("data-w6col-dir", dir);
document.startViewTransition(swap).finished.finally(function () { tag(views[i], false); html.removeAttribute("data-w6col-dir"); busy = false; });
} else { root.setAttribute("data-fb", ""); swap(); }
}
root.addEventListener("click", function (e) {
var a = e.target.closest("[data-go]");
if (!a) return;
e.preventDefault(); auto = false; go(+a.getAttribute("data-go"), true);
});
["pointerdown", "keydown"].forEach(function (n) { root.addEventListener(n, function () { auto = false; }); });
// Idle demo: changes page now and then while the piece is on screen and nobody has used it.
function tick() {
timer = 0;
if (!auto || !seen || rm.matches) return;
go((cur + 1) % views.length, false);
turns++;
timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]);
}
// The demo waits for the page to finish loading, so the first thing anyone sees is the resting view.
function kick() { if (seen && auto && !timer && document.readyState == "complete") timer = setTimeout(tick, DEMO[Math.min(turns, DEMO.length - 1)]); }
addEventListener("load", kick);
new IntersectionObserver(function (e) {
seen = e[0].isIntersecting;
if (seen) kick(); else { clearTimeout(timer); timer = 0; }
}).observe(root);
//BODY-END
})();
</script>
With reduced motion: Text and photo change together in one step, with no movement in either column.
Running cost: Four snapshots, two per column, move by transform for just over half a second, then the page is static again.
- Change the `48px` in the `w6col-up` and `w6col-down` text keyframes to move the words further.
- Use `--w6col-blue` on `.w6col` for the page number, bullets, active menu pill and focus ring.
- Add a fourth page by copying a `section.w6col-view` and its menu link with the next `data-go` number.
Performance notes
The browser captures the old and new views as images and animates those, so the real page is updated once and never animated itself. Keep the animated groups to the parts that matter, such as one shared image and the main content, because every named element becomes its own captured layer.
The fallbacks move a single cover layer or the content wrapper with transform and opacity, and keep the new content in the DOM from the start, so focus and screen reader output follow the update immediately rather than after the animation.
Questions
What is the View Transitions API?
A browser feature that animates between two states of the page. You wrap a DOM update in document.startViewTransition(), and the browser captures before and after snapshots that you can animate with CSS pseudo-elements such as ::view-transition-old and ::view-transition-new.
Which browsers support view transitions?
According to MDN, same-document view transitions work in Chrome and Edge from 111, Safari from 18 and Firefox from 144. Cross-document transitions with @view-transition work in Chrome and Edge from 126 and Safari from 18.2, but not yet in Firefox.
How do I add page transitions in React?
Wrap the state change or router navigation that swaps the view in document.startViewTransition, and use flushSync so React renders the new view inside the callback. The React version of each piece here shows the pattern with a fallback.
Do page transitions hurt accessibility?
Not if they are short, move focus to the new content's heading, and turn off for reduced motion. By default the browser crossfades the old and new snapshots, so a reduced-motion rule should set animation: none on the view transition pseudo-elements, as these pieces do.
More collections: Preloaders and Page Loading Screens, Full-Screen Menus and Menu Reveals, Scroll Animations Without a Library. All tabs and navigation. Build your site free to have a full site built around them.
Product
Who It's For
- For Agencies
- For Freelancers
- For Hosting Providers
- For SaaS Platforms
- For Startups
- For Financial Services
- For Healthcare
Features
Resources
- Blog
- Help Center
- Free Business Tools
- Free UI Components
- Website Templates
- Template Collections
- Website Examples
- Guides
- Comparisons
- Alternatives
- Best Lists
- Reviews
- Pricing Guides
- Use Cases
- Glossary & Guides
- Integrations
- Developers
- Benchmark
- Windows App