Back to the library
Interpret swap, word cascade
Variant: Cascade
Swaps a message between its original and translated text in place. Each word blurs upward and fades out while the new word rises in from below, and the language pill moves its fill to the language now showing. Use it on a 'Translate' / 'Show original' toggle so the reader can see the text changed without the block jumping. Words are offset by 50ms so the change reads left to right, and the exit (160ms) is shorter than the entry (220ms), so the new text lands last.
translatetext-swapstaggerstate-changei18n
The source
A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Interpret swap — cascade</title>
<style>
:root {
/* Neutrals — fixed, never remixed. */
--ivory: #faf9f5;
--paper: #ffffff;
--oat: #e3dacc;
--slate: #141413;
/* Knobs — the remix API. A knob exists iff declared here and used below. */
--hue: 38.8;
--lift: 0;
--chroma: 1;
--round: 1; /* include ONLY if at least one border-radius is wrapped below */
--speed: 1;
/* Accents — derived from the knobs with the family's offsets baked in,
so one hue roll moves them together. Defaults reproduce the original hex
(#d97757 / #b85c3e / #788c5d / #b04a3f). */
--clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
--clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
--olive: oklch(calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3));
--rust: oklch(calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3));
/* Clock — every duration in the document runs off --t. */
--cycle: 4.8s; /* the authored master loop */
--t: calc(var(--cycle) / var(--speed));
--ease-out: cubic-bezier(0.23, 1, 0.32, 1); /* include only if used */
--_stagger: calc(50ms / var(--speed));
--_tint: color-mix(in oklch, var(--clay) 18%, var(--paper));
--_edge: color-mix(in oklch, var(--clay) 45%, var(--paper));
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
min-height: 100vh;
display: grid;
place-items: center;
background: var(--ivory);
color: var(--slate);
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.card {
width: min(340px, 88vw);
padding: clamp(16px, 5vw, 24px);
background: var(--paper);
border: 1px solid var(--oat);
border-radius: calc(14px * var(--round));
display: grid;
gap: clamp(12px, 3.5vw, 18px);
}
.langs { display: flex; align-items: center; gap: 8px; }
.langs svg { opacity: 0.45; }
.pill {
position: relative;
isolation: isolate;
padding: 4px 10px;
border: 1px solid var(--oat);
border-radius: 999px;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.06em;
line-height: 1.2;
}
.pill::before {
content: "";
position: absolute;
inset: -1px;
z-index: -1;
border-radius: inherit;
background: var(--_tint);
border: 1px solid var(--_edge);
}
/* The pill fill rides the same fade curves as the text, so the label and the words agree on every frame. */
.pill--src::before { animation: src-fade var(--t) var(--ease-out) infinite both; }
.pill--tgt::before { animation: tgt-fade var(--t) var(--ease-out) infinite both; }
.phrase {
display: grid;
margin: 0;
font-size: clamp(18px, 5.4vw, 24px);
font-weight: 500;
line-height: 1.3;
letter-spacing: -0.01em;
}
.line { grid-area: 1 / 1; }
.w {
display: inline-block;
animation-duration: var(--t);
animation-timing-function: var(--ease-out);
animation-iteration-count: infinite;
animation-fill-mode: both;
animation-delay: calc(var(--_i) * var(--_stagger));
}
.src .w { animation-name: src-fade, src-move; }
.tgt .w { animation-name: tgt-fade, tgt-move; }
/* 1% = 48ms. Swap at 37.5% (1.8s), revert at 87.5% (4.2s). Exit 160ms, enter 220ms. */
@keyframes src-fade {
0%, 37.5% { opacity: 1; }
40.83%, 87.5% { opacity: 0; }
92.08%, 100% { opacity: 1; }
}
@keyframes src-move {
0%, 37.5% { transform: translateY(0); filter: blur(0); }
40.83%, 87.49% { transform: translateY(-0.35em); filter: blur(3px); }
87.5% { transform: translateY(0.35em); filter: blur(3px); }
92.08%, 100% { transform: translateY(0); filter: blur(0); }
}
@keyframes tgt-fade {
0%, 37.5% { opacity: 0; }
42.08%, 87.5% { opacity: 1; }
90.83%, 100% { opacity: 0; }
}
@keyframes tgt-move {
0%, 37.5% { transform: translateY(0.35em); filter: blur(3px); }
42.08%, 87.5% { transform: translateY(0); filter: blur(0); }
90.83% { transform: translateY(-0.35em); filter: blur(3px); }
90.84%, 100% { transform: translateY(0.35em); filter: blur(3px); }
}
@media (max-width: 380px) {
.card { padding: 16px; }
.phrase { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
.w, .pill::before { animation-duration: calc(var(--cycle) * 2 / var(--speed)); }
.w { animation-delay: calc(var(--_i) * var(--_stagger) * 2); }
.src .w { animation-name: src-fade; }
.tgt .w { animation-name: tgt-fade; }
}
</style>
</head>
<body>
<div class="card">
<div class="langs">
<span class="pill pill--src">EN</span>
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M3 8h10M9.5 4.5 13 8l-3.5 3.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>
<span class="pill pill--tgt">ES</span>
</div>
<p class="phrase">
<span class="line src" lang="en"><span class="w" style="--_i:0">Where</span> <span class="w" style="--_i:1">is</span> <span class="w" style="--_i:2">the</span> <span class="w" style="--_i:3">station?</span></span>
<span class="line tgt" lang="es"><span class="w" style="--_i:0">¿Dónde</span> <span class="w" style="--_i:1">está</span> <span class="w" style="--_i:2">la</span> <span class="w" style="--_i:3">estación?</span></span>
</p>
</div>
</body>
</html>
The variant family
Same idea, one axis moved. Compare them side by side before you commit.