Skeleton-to-Content Handoff
骨架屏无跳动交接
A fixed-size skeleton hands off to content measured for the same space while loading state changes.
Where to use it
Keep results or dashboard cards stable when a delayed response fills their slots. Give the placeholder the resolved card’s dimensions so nearby controls keep their positions throughout the handoff.
Practical example
On a utilities dashboard, the monthly usage card starts as a rectangle with a reserved heading and chart area. When readings arrive, the chart fades into the same slot and the payment button below stays in place.
AI prompt
Give [card slot] a skeleton handoff. Reserve the final geometry, overlay the placeholder and resolved card in one grid cell, mark busy while waiting, and fade content in only after the real result is available.
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>Skeleton-to-Content Handoff</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;
}
.ui { width: min(100%, 238px); display: grid; gap: 8px; position: relative; font-size: 12px; line-height: 1.35; }
.ui .surface { min-width: 0; border: 1px solid #676591; border-radius: 10px; background: #282744; padding: 8px; }
.ui .bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ui .actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; }
.ui .muted { color: #cecae9; font-size: 11px; }
.ui .center { text-align: center; }
.ui .mono { font: 11px ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.ui p { margin: 0; }
.ui .button { min-height: 30px; padding: 4px 7px; border-radius: 7px; border: 1px solid #79779f; background: #3d3a60; color: #f9f5ff; font-size: 11px; font-weight: 650; cursor: pointer; }
.ui .button:hover { background: #4e4976; }
.ui .primary { background: #c5eeec; border-color: #dafaee; color: #17213b; }
.ui .primary:hover { background: #e3fff9; }
.ui .button:disabled { opacity: .6; cursor: default; }
.ui .field { min-width: 0; width: 100%; border: 1px solid #79779f; border-radius: 6px; background: #1b1a31; color: #faf5ff; padding: 5px 7px; font-size: 12px; }
.ui .field::placeholder { color: #c2bcdd; }
.ui input[type="range"] { accent-color: #b8ebe0; width: 100%; min-width: 0; margin: 0; }
.ui button { font: inherit; }
.ui [hidden] { display: none !important; }
.ui progress { accent-color: #b8ebe0; }
@media (prefers-reduced-motion: reduce) {
.ui *, .ui *::after, .ui *::before { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
.handoff{height:79px;display:grid;align-items:center}.final-card,.ghost{grid-area:1/1;display:grid;grid-template-columns:47px minmax(0,1fr);align-items:center;gap:8px}.art,.ghost i{width:47px;height:47px;border-radius:7px}.art{display:grid;place-items:center;background:conic-gradient(from 50deg,#8eabd9,#5c578b,#66c9b4,#8eabd9);font-size:23px;color:#202840}.ghost i,.ghost b{background:#4b456d;display:block}.ghost b{height:8px;border-radius:6px;margin:6px 0;width:82%}.ghost b+ b{width:60%}.handoff[data-in] .final-card{animation:reveal-card .24s ease both}@keyframes reveal-card{from{opacity:.12}to{opacity:1}}
</style>
</head>
<body>
<main class="demo">
<div class="ui"><div class="surface handoff" aria-busy="false"><div class="final-card"><div class="art">◐</div><div><strong>Observation</strong><p class="muted">A river crossing</p></div></div><div class="ghost" aria-hidden="true" hidden><i></i><span><b></b><b></b></span></div></div><div class="bar"><span class="muted" role="status">Loaded</span><button class="button primary reload" type="button">Reload</button></div></div>
</main>
<script>
const stage = document.querySelector('.handoff');
const actual = stage.querySelector('.final-card');
const placeholder = stage.querySelector('.ghost');
const reload = document.querySelector('.reload');
const status = document.querySelector('[role=status]');
reload.addEventListener('click', () => {
reload.disabled = true; stage.removeAttribute('data-in'); stage.setAttribute('aria-busy', 'true'); actual.hidden = true; placeholder.hidden = false; status.textContent = "Fetching sample…";
setTimeout(() => { placeholder.hidden = true; actual.hidden = false; stage.setAttribute('data-in', ''); stage.setAttribute('aria-busy', 'false'); reload.disabled = false; status.textContent = "Loaded"; }, 900);
});
</script>
</body>
</html>Original example by UI Skills