Split-Flap Display
翻牌显示
Each character flips through intermediate letters before settling into a new word.
Where to use it
Animate destinations, short countdown captions, or status labels. Use fixed-width cells, keep the sequence short, and announce the finished word to assistive technology.
Practical example
A station-inspired travel planner flips its departure board to a different city. The characters settle from left to right.
Also called
- Solari Board
- Flap Display
AI prompt
Render [short text] as a Split-Flap Display. Each character flips through intermediate letters before landing on the target. Stagger columns slightly. For reduced motion, set the final text immediately.
Example code
Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.
View HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Split-Flap Display</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.demo {
background: radial-gradient(ellipse at 50% 11%, #4e4635, #28271f 74%, #1d1c18);
}
.flap-scene { display: grid; justify-items: center; width: min(100%, 442px); gap: 17px; }
.flap-board {
display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px;
width: min(100%, 355px); padding: 7px; border: 1px solid #6b6250; border-radius: 8px;
background: #161612; box-shadow: 0 9px 17px #16140d8c, inset 0 1px #fff1be26;
}
.flap-cell {
position: relative; height: clamp(35px, 20vh, 70px); perspective: 110px;
color: #eee2b4; font: 700 clamp(20px, 9vw, 40px)/1 ui-monospace, monospace;
font-variant-numeric: tabular-nums;
}
.flap-half {
position: absolute; display: block; inset-inline: 0; height: 50%; overflow: hidden;
background: linear-gradient(#2d2f28, #3a3a2e);
}
.flap-half[hidden] { display: none; }
.flap-top {
top: 0; border-radius: 4px 4px 1px 1px; border-bottom: 1px solid #1a1915;
}
.flap-bottom {
bottom: 0; border-radius: 1px 1px 4px 4px; background: linear-gradient(#282821, #323229);
}
.flap-half span { position: absolute; left: 50%; }
.flap-top span { top: 100%; transform: translate(-50%, -50%); }
.flap-bottom span { top: 0; transform: translate(-50%, -50%); }
.flap-moving { z-index: 1; transform-origin: center bottom; }
.flap-moving.flap-bottom { transform-origin: center top; }
.flap-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[data-flap-next] { background: #3a372a; border-color: #827758; color: #f1e3b3; }
[data-flap-next]:focus-visible { outline-color: #f1e3b3; }
</style>
</head>
<body>
<main class="demo">
<div class="flap-scene">
<div class="flap-board" aria-hidden="true">
<span class="flap-cell">
<span class="flap-half flap-top"><span>L</span></span>
<span class="flap-half flap-bottom"><span>L</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
<span class="flap-cell">
<span class="flap-half flap-top"><span>O</span></span>
<span class="flap-half flap-bottom"><span>O</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
<span class="flap-cell">
<span class="flap-half flap-top"><span>N</span></span>
<span class="flap-half flap-bottom"><span>N</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
<span class="flap-cell">
<span class="flap-half flap-top"><span>D</span></span>
<span class="flap-half flap-bottom"><span>D</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
<span class="flap-cell">
<span class="flap-half flap-top"><span>O</span></span>
<span class="flap-half flap-bottom"><span>O</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
<span class="flap-cell">
<span class="flap-half flap-top"><span>N</span></span>
<span class="flap-half flap-bottom"><span>N</span></span>
<span class="flap-half flap-top flap-moving" hidden><span></span></span>
</span>
</div>
<output class="flap-status" aria-live="polite">LONDON</output>
<button class="demo-button" type="button" data-flap-next>Next destination</button>
</div>
</main>
<script>
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const destinations = ["LONDON","BERLIN","BOSTON"];
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const board = document.querySelector('.flap-board');
const cells = Array.from(board.children, (cell) => {
const [top, bottom, moving] = cell.children;
return { top: top.firstElementChild, bottom: bottom.firstElementChild, moving, face: moving.firstElementChild };
});
const next = document.querySelector('[data-flap-next]');
const status = document.querySelector('.flap-status');
const liveAnimations = new Set();
let current = 0;
let pending = 0;
function wait(duration) {
return new Promise((resolve) => setTimeout(resolve, duration));
}
function setLetter(cell, letter) {
cell.top.textContent = letter;
cell.bottom.textContent = letter;
cell.moving.hidden = true;
}
async function swing(cell, transforms, easing) {
const animation = cell.moving.animate(transforms.map((transform) => ({ transform })), {
duration: 61, easing,
});
liveAnimations.add(animation);
try {
await animation.finished;
} catch {
// A new motion preference or destination can finish this flip early.
} finally {
liveAnimations.delete(animation);
}
}
async function animateCell(cell, letter, index, sequence) {
await wait(index * 46);
const previous = alphabet.indexOf(cell.top.textContent);
const destination = alphabet.indexOf(letter);
const distance = (destination - previous + alphabet.length) % alphabet.length;
const steps = Math.min(distance, 4);
for (let step = 1; step <= steps; step += 1) {
if (sequence !== pending || reduced.matches) return;
const glyph = alphabet[(previous + Math.ceil(distance * step / steps)) % alphabet.length];
cell.face.textContent = cell.bottom.textContent;
cell.moving.classList.replace('flap-bottom', 'flap-top');
cell.moving.hidden = false;
cell.top.textContent = glyph;
await swing(cell, ['rotateX(0deg)', 'rotateX(-92deg)'], 'ease-in');
if (sequence !== pending || reduced.matches) return;
cell.face.textContent = glyph;
cell.moving.classList.replace('flap-top', 'flap-bottom');
await swing(cell, ['rotateX(92deg)', 'rotateX(0deg)'], 'ease-out');
if (sequence !== pending || reduced.matches) return;
setLetter(cell, glyph);
}
}
function settle() {
pending += 1;
liveAnimations.forEach((animation) => animation.cancel());
const word = destinations[current];
cells.forEach((cell, index) => setLetter(cell, word[index]));
status.textContent = word;
board.removeAttribute('aria-busy');
}
next.addEventListener('click', async () => {
settle();
current = (current + 1) % destinations.length;
if (reduced.matches) {
settle();
return;
}
const sequence = pending;
const word = destinations[current];
board.setAttribute('aria-busy', 'true');
await Promise.all(cells.map((cell, index) => animateCell(cell, word[index], index, sequence)));
if (sequence === pending) settle();
});
reduced.addEventListener('change', settle);
</script>
</body>
</html>Original example by UI Skills