Empty States — Skeleton + spinner + progressive load set
A side-by-side gallery of loading-state primitives for product UIs — shimmering skeletons for list rows, profile cards and table data, an inline spinner button with a pending-to-resolved cycle, a determinate upload progress bar with live percentage, and a staggered progressive content reveal. A segmented switcher highlights and replays each variant, while a single Reload button replays the whole loading-to-loaded sequence with an accessible status line and toast feedback.
MCP
程式碼
:root {
--brand: #5b5bf0;
--brand-d: #4646d6;
--brand-700: #3a3ab8;
--brand-50: #eef0ff;
--accent: #00b4a6;
--accent-soft: #d8f5f2;
--ink: #101322;
--ink-2: #3a4060;
--muted: #6c7393;
--bg: #f6f7fb;
--white: #ffffff;
--surface: #ffffff;
--line: rgba(16, 19, 34, 0.1);
--line-2: rgba(16, 19, 34, 0.16);
--ok: #2f9e6f;
--warn: #d98a2b;
--danger: #d4503e;
--r-sm: 8px;
--r-md: 14px;
--r-lg: 20px;
--sh-1: 0 1px 2px rgba(16, 19, 34, 0.08);
--sh-2: 0 8px 24px rgba(16, 19, 34, 0.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
font-family: "Inter", system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--ink);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.page {
max-width: 1080px;
margin: 0 auto;
padding: 40px 24px 80px;
}
/* ---------- Masthead ---------- */
.masthead {
display: flex;
flex-wrap: wrap;
gap: 24px;
align-items: flex-end;
justify-content: space-between;
}
.masthead__lead { max-width: 560px; }
.eyebrow {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--brand-d);
background: var(--brand-50);
padding: 5px 11px;
border-radius: 999px;
}
.eyebrow svg { animation: slow-spin 8s linear infinite; }
h1 {
font-size: clamp(26px, 4vw, 34px);
font-weight: 800;
letter-spacing: -0.02em;
margin: 14px 0 8px;
}
.masthead__sub {
margin: 0;
color: var(--ink-2);
font-size: 15px;
}
.masthead__sub strong { color: var(--ink); font-weight: 700; }
.masthead__controls {
display: flex;
flex-direction: column;
gap: 12px;
align-items: flex-end;
}
/* ---------- Segmented control ---------- */
.segmented {
display: inline-flex;
background: var(--white);
border: 1px solid var(--line);
border-radius: 999px;
padding: 4px;
box-shadow: var(--sh-1);
}
.seg {
border: 0;
background: transparent;
font: inherit;
font-size: 13px;
font-weight: 600;
color: var(--muted);
padding: 7px 14px;
border-radius: 999px;
cursor: pointer;
transition: color 0.15s, background 0.15s;
}
.seg:hover { color: var(--ink); }
.seg[aria-selected="true"] {
background: var(--brand);
color: #fff;
box-shadow: 0 2px 6px rgba(91, 91, 240, 0.35);
}
.seg:focus-visible {
outline: 2px solid var(--brand-d);
outline-offset: 2px;
}
/* ---------- Buttons ---------- */
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
font: inherit;
font-size: 14px;
font-weight: 600;
border: 1px solid transparent;
border-radius: var(--r-sm);
padding: 10px 16px;
cursor: pointer;
transition: transform 0.08s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand-d); outline-offset: 2px; }
.btn--primary {
background: var(--brand);
color: #fff;
box-shadow: 0 2px 8px rgba(91, 91, 240, 0.32);
}
.btn--primary:hover { background: var(--brand-d); }
.btn--accent {
background: var(--accent);
color: #fff;
box-shadow: 0 2px 8px rgba(0, 180, 166, 0.3);
}
.btn--accent:hover { background: #009b8f; }
.btn__icon { transition: transform 0.4s ease; }
#reloadBtn.is-spinning .btn__icon { animation: slow-spin 0.7s linear infinite; }
.btn[disabled], .btn[aria-busy="true"] { cursor: progress; }
/* ---------- Status line ---------- */
.status-line {
display: flex;
align-items: center;
gap: 9px;
margin: 26px 0 18px;
font-size: 13px;
color: var(--ink-2);
font-weight: 500;
}
.dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--ok);
box-shadow: 0 0 0 4px rgba(47, 158, 111, 0.16);
}
.dot[data-state="loading"] {
background: var(--brand);
box-shadow: 0 0 0 4px rgba(91, 91, 240, 0.16);
animation: pulse 1.1s ease-in-out infinite;
}
/* ---------- Grid ---------- */
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 18px;
}
.panel--wide { grid-column: 1 / -1; }
/* ---------- Panel ---------- */
.panel {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--r-lg);
box-shadow: var(--sh-1);
overflow: hidden;
transition: box-shadow 0.2s, opacity 0.25s, filter 0.25s;
}
.panel:hover { box-shadow: var(--sh-2); }
.grid.dim .panel:not(.is-active) {
opacity: 0.38;
filter: saturate(0.6);
}
.grid.dim .panel.is-active {
box-shadow: 0 0 0 2px var(--brand), var(--sh-2);
}
.panel__head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 18px;
border-bottom: 1px solid var(--line);
}
.panel__head h2 {
margin: 0;
font-size: 14px;
font-weight: 700;
letter-spacing: -0.01em;
}
.panel__body { padding: 18px; min-height: 132px; }
.panel__body--center {
display: flex;
align-items: center;
justify-content: center;
}
/* ---------- Tags ---------- */
.tag {
display: inline-flex;
align-items: center;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.02em;
padding: 3px 9px;
border-radius: 999px;
text-transform: uppercase;
}
.tag--brand { background: var(--brand-50); color: var(--brand-d); }
.tag--ok { background: rgba(47, 158, 111, 0.14); color: var(--ok); }
.tag--warn { background: rgba(217, 138, 43, 0.16); color: var(--warn); }
.tag--danger { background: rgba(212, 80, 62, 0.14); color: var(--danger); }
/* ---------- Skeleton primitives ---------- */
.sk {
display: block;
border-radius: var(--r-sm);
background: linear-gradient(
100deg,
rgba(16, 19, 34, 0.06) 30%,
rgba(16, 19, 34, 0.12) 50%,
rgba(16, 19, 34, 0.06) 70%
);
background-size: 220% 100%;
animation: shimmer 1.3s ease-in-out infinite;
}
.sk-line { height: 11px; border-radius: 6px; }
.sk-line + .sk-line { margin-top: 8px; }
.w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; }
.w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; }
.center { margin-left: auto; margin-right: auto; }
.sk-avatar { width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; }
.sk-row { display: flex; align-items: center; gap: 13px; padding: 10px 0; }
.sk-row + .sk-row { border-top: 1px solid var(--line); }
.sk-lines { flex: 1; }
.sk-profile { display: flex; flex-direction: column; align-items: center; }
.sk-cover { width: 100%; height: 46px; border-radius: var(--r-md); }
.sk-portrait { width: 60px; height: 60px; border-radius: 50%; margin: -28px 0 12px; border: 3px solid var(--surface); }
.sk-chips { display: flex; gap: 8px; margin-top: 14px; }
.sk-chip { width: 56px; height: 22px; border-radius: 999px; }
.sk-table { width: 100%; border-collapse: collapse; }
.sk-table th {
text-align: left;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--muted);
font-weight: 700;
padding: 0 10px 10px;
}
.sk-table td { padding: 11px 10px; border-top: 1px solid var(--line); }
.sk-pill { width: 54px; height: 18px; border-radius: 999px; }
/* ---------- Real content (loaded) ---------- */
[data-loaded] { animation: fade-up 0.35s ease both; }
.real-list { list-style: none; margin: 0; padding: 0; }
.real-list li {
display: flex;
align-items: center;
gap: 13px;
padding: 11px 0;
}
.real-list li + li { border-top: 1px solid var(--line); }
.real-lines { flex: 1; display: flex; flex-direction: column; }
.real-lines strong { font-size: 14px; font-weight: 600; }
.real-lines small { font-size: 12px; color: var(--muted); }
.real-lines em { font-style: normal; color: var(--brand-d); font-weight: 600; }
.ava {
width: 40px; height: 40px;
border-radius: 50%;
display: grid;
place-items: center;
color: #fff;
font-size: 13px;
font-weight: 700;
flex: 0 0 auto;
}
.ava--violet { background: linear-gradient(135deg, #6f6ff5, #4646d6); }
.ava--teal { background: linear-gradient(135deg, #14c4b6, #008f84); }
.ava--amber { background: linear-gradient(135deg, #f0b14a, #d98a2b); }
.real-profile { text-align: center; }
.real-profile .cover {
height: 46px;
border-radius: var(--r-md);
background: linear-gradient(120deg, var(--brand) 0%, var(--accent) 100%);
}
.portrait {
display: grid;
place-items: center;
width: 60px; height: 60px;
border-radius: 50%;
margin: -28px auto 10px;
border: 3px solid var(--surface);
background: linear-gradient(135deg, #6f6ff5, #4646d6);
color: #fff;
font-weight: 700;
font-size: 18px;
}
.real-profile h3 { margin: 0; font-size: 16px; font-weight: 700; }
.real-profile .role { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.chips { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.chip {
font-size: 11px;
font-weight: 600;
color: var(--ink-2);
background: var(--bg);
border: 1px solid var(--line);
padding: 4px 10px;
border-radius: 999px;
}
.real-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.real-table th {
text-align: left;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--muted);
font-weight: 700;
padding: 0 10px 10px;
}
.real-table td { padding: 11px 10px; border-top: 1px solid var(--line); }
.real-table td:first-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.real-table td:nth-child(3) { font-variant-numeric: tabular-nums; }
/* ---------- Spinner button ---------- */
.spinner-demo { text-align: center; }
.hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); max-width: 240px; }
.spinner {
width: 16px; height: 16px;
border-radius: 50%;
border: 2.5px solid rgba(255, 255, 255, 0.45);
border-top-color: #fff;
animation: slow-spin 0.7s linear infinite;
display: none;
}
.action-btn[aria-busy="true"] .spinner { display: inline-block; }
.action-btn[aria-busy="true"] { opacity: 0.92; }
.result {
display: inline-flex;
align-items: center;
gap: 7px;
margin: 16px 0 0;
font-size: 13px;
font-weight: 600;
color: var(--ok);
animation: fade-up 0.3s ease both;
}
/* ---------- Progress bar ---------- */
.progress-demo { width: 100%; }
.progress-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
font-size: 13px;
}
.file {
display: inline-flex;
align-items: center;
gap: 7px;
font-weight: 600;
color: var(--ink-2);
}
.file svg { color: var(--brand); }
.pct { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand-d); }
.progress {
height: 10px;
border-radius: 999px;
background: var(--bg);
border: 1px solid var(--line);
overflow: hidden;
}
.progress__fill {
display: block;
height: 100%;
width: 0%;
border-radius: 999px;
background: linear-gradient(90deg, var(--brand), var(--accent));
transition: width 0.18s ease;
}
.progress.is-done .progress__fill { background: var(--ok); }
.progress-meta { margin: 11px 0 0; font-size: 12px; color: var(--muted); }
.progress-meta.is-done { color: var(--ok); font-weight: 600; }
/* ---------- Progressive reveal ---------- */
.reveal-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
}
.tile {
background: var(--bg);
border: 1px solid var(--line);
border-radius: var(--r-md);
padding: 16px 14px;
display: flex;
flex-direction: column;
gap: 4px;
transition: box-shadow 0.18s, transform 0.18s;
}
.tile:hover { box-shadow: var(--sh-1); transform: translateY(-2px); }
.tile[data-reveal] {
opacity: 0;
transform: translateY(10px);
}
.tile.is-in {
opacity: 1;
transform: translateY(0);
transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.tile__kpi { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile__label { font-size: 12px; color: var(--muted); }
.tile__delta {
font-size: 11px;
font-weight: 700;
margin-top: 4px;
width: max-content;
padding: 2px 8px;
border-radius: 999px;
}
.tile__delta.up { color: var(--ok); background: rgba(47, 158, 111, 0.13); }
.tile__delta.down { color: var(--ok); background: rgba(47, 158, 111, 0.13); }
.tile__delta.flat { color: var(--muted); background: var(--bg); border: 1px solid var(--line); }
/* ---------- Toast ---------- */
.toast-wrap {
position: fixed;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-direction: column;
gap: 10px;
z-index: 50;
pointer-events: none;
}
.toast {
display: flex;
align-items: center;
gap: 9px;
background: var(--ink);
color: #fff;
font-size: 13px;
font-weight: 600;
padding: 11px 16px;
border-radius: var(--r-md);
box-shadow: var(--sh-2);
animation: toast-in 0.28s ease both;
}
.toast.is-out { animation: toast-out 0.25s ease forwards; }
.toast svg { color: var(--accent); flex: 0 0 auto; }
/* ---------- Keyframes ---------- */
@keyframes shimmer {
0% { background-position: 180% 0; }
100% { background-position: -180% 0; }
}
@keyframes slow-spin { to { transform: rotate(360deg); } }
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.35); }
}
@keyframes fade-up {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-in {
from { opacity: 0; transform: translateY(12px) scale(0.96); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
to { opacity: 0; transform: translateY(8px) scale(0.97); }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.001ms !important;
}
}
/* ---------- Responsive ---------- */
@media (max-width: 760px) {
.grid { grid-template-columns: 1fr; }
.reveal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
.page { padding: 28px 16px 64px; }
.masthead { align-items: flex-start; }
.masthead__controls { align-items: stretch; width: 100%; }
.segmented { overflow-x: auto; justify-content: flex-start; }
.btn--primary { justify-content: center; }
h1 { font-size: 24px; }
.reveal-grid { grid-template-columns: 1fr; }
.real-table, .sk-table { font-size: 12px; }
.real-table td, .real-table th,
.sk-table td, .sk-table th { padding-left: 6px; padding-right: 6px; }
}(function () {
"use strict";
var prefersReduced = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
/* ---------- Toast helper ---------- */
var toastWrap = document.getElementById("toastWrap");
function toast(msg) {
var el = document.createElement("div");
el.className = "toast";
el.setAttribute("role", "status");
el.innerHTML =
'<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg><span></span>';
el.querySelector("span").textContent = msg;
toastWrap.appendChild(el);
var ttl = setTimeout(function () {
el.classList.add("is-out");
el.addEventListener("animationend", function () {
el.remove();
});
}, 2600);
el.addEventListener("click", function () {
clearTimeout(ttl);
el.remove();
});
}
/* ---------- Status line ---------- */
var statusDot = document.getElementById("statusDot");
var statusText = document.getElementById("statusText");
function setStatus(state, text) {
statusDot.dataset.state = state;
statusText.textContent = text;
}
/* ---------- Timer registry (so reloads cancel cleanly) ---------- */
var timers = [];
function later(fn, ms) {
var id = setTimeout(fn, prefersReduced ? Math.min(ms, 80) : ms);
timers.push(id);
return id;
}
function clearTimers() {
timers.forEach(clearTimeout);
timers = [];
}
/* ---------- Skeleton panels: toggle loading <-> loaded ---------- */
var stages = Array.prototype.slice.call(
document.querySelectorAll(".panel[data-variant='skeleton'] [data-stage]")
);
function skeletonShow(loading) {
stages.forEach(function (stage) {
var load = stage.querySelector("[data-loading]");
var done = stage.querySelector("[data-loaded]");
if (load) load.hidden = !loading;
if (done) done.hidden = loading;
});
}
/* ---------- Spinner button ---------- */
var spinnerBtn = document.getElementById("spinnerBtn");
var spinnerResult = document.getElementById("spinnerResult");
var spinnerLabel = spinnerBtn.querySelector(".action-btn__label");
function runSpinner(silent) {
spinnerResult.hidden = true;
spinnerBtn.setAttribute("aria-busy", "true");
spinnerBtn.disabled = true;
spinnerLabel.textContent = "Sending…";
later(function () {
spinnerBtn.setAttribute("aria-busy", "false");
spinnerBtn.disabled = false;
spinnerLabel.textContent = "Send payout";
spinnerResult.hidden = false;
if (!silent) toast("Payout sent");
}, 1600);
}
spinnerBtn.addEventListener("click", function () {
runSpinner(false);
});
/* ---------- Progress bar ---------- */
var progressBar = document.getElementById("progressBar");
var progressFill = document.getElementById("progressFill");
var progressPct = document.getElementById("progressPct");
var progressMeta = document.getElementById("progressMeta");
var progressInterval = null;
function resetProgress() {
if (progressInterval) {
clearInterval(progressInterval);
progressInterval = null;
}
progressBar.classList.remove("is-done");
progressMeta.classList.remove("is-done");
progressFill.style.width = "0%";
progressPct.textContent = "0%";
progressBar.setAttribute("aria-valuenow", "0");
progressMeta.textContent = "Waiting to start…";
}
function runProgress(silent) {
resetProgress();
var pct = 0;
progressMeta.textContent = "Uploading quarterly-report.pdf…";
progressInterval = setInterval(
function () {
// ease-out style increments
var step = Math.max(1, Math.round((100 - pct) * 0.12));
pct = Math.min(100, pct + step);
progressFill.style.width = pct + "%";
progressPct.textContent = pct + "%";
progressBar.setAttribute("aria-valuenow", String(pct));
if (pct >= 100) {
clearInterval(progressInterval);
progressInterval = null;
progressBar.classList.add("is-done");
progressMeta.classList.add("is-done");
progressMeta.textContent = "Upload complete · 2.4 MB";
if (!silent) toast("Upload complete");
}
},
prefersReduced ? 30 : 130
);
timers.push({ stop: function () {} }); // marker; interval cleared in reset
}
/* ---------- Progressive staggered reveal ---------- */
var revealTiles = Array.prototype.slice.call(
document.querySelectorAll(".tile[data-reveal]")
);
function resetReveal() {
revealTiles.forEach(function (t) {
t.classList.remove("is-in");
});
}
function runReveal() {
resetReveal();
revealTiles.forEach(function (tile, i) {
later(function () {
tile.classList.add("is-in");
}, 140 + i * 130);
});
}
/* ---------- Full reload sequence ---------- */
var reloadBtn = document.getElementById("reloadBtn");
function reloadAll() {
clearTimers();
if (progressInterval) {
clearInterval(progressInterval);
progressInterval = null;
}
reloadBtn.classList.add("is-spinning");
reloadBtn.disabled = true;
setStatus("loading", "Loading all primitives…");
// 1. show every loading state
skeletonShow(true);
resetProgress();
resetReveal();
spinnerResult.hidden = true;
// 2. kick the live ones
runSpinner(true);
runProgress(true);
// 3. resolve skeletons + reveal after a beat, then settle
later(function () {
skeletonShow(false);
}, 1500);
later(function () {
runReveal();
}, 1500);
later(function () {
reloadBtn.classList.remove("is-spinning");
reloadBtn.disabled = false;
setStatus("idle", "Content loaded — replay any primitive above.");
toast("All states reloaded");
}, 2500);
}
reloadBtn.addEventListener("click", reloadAll);
/* ---------- Variant switcher (segmented control) ---------- */
var segs = Array.prototype.slice.call(document.querySelectorAll(".seg"));
var grid = document.getElementById("gallery");
var panels = Array.prototype.slice.call(grid.querySelectorAll(".panel"));
function selectVariant(variant, replay) {
segs.forEach(function (s) {
s.setAttribute(
"aria-selected",
s.dataset.variant === variant ? "true" : "false"
);
});
if (variant === "all") {
grid.classList.remove("dim");
panels.forEach(function (p) {
p.classList.remove("is-active");
});
} else {
grid.classList.add("dim");
panels.forEach(function (p) {
p.classList.toggle("is-active", p.dataset.variant === variant);
});
}
if (!replay) return;
// replay just the focused primitive
if (variant === "skeleton") {
skeletonShow(true);
setStatus("loading", "Loading skeleton placeholders…");
later(function () {
skeletonShow(false);
setStatus("idle", "Skeleton content loaded.");
}, 1400);
} else if (variant === "spinner") {
runSpinner(true);
setStatus("loading", "Pending action in flight…");
later(function () {
setStatus("idle", "Action resolved.");
}, 1700);
} else if (variant === "progress") {
runProgress(true);
setStatus("loading", "Upload in progress…");
later(function () {
setStatus("idle", "Upload finished.");
}, 1500);
} else if (variant === "reveal") {
runReveal();
setStatus("loading", "Revealing tiles…");
later(function () {
setStatus("idle", "Tiles revealed.");
}, 900);
}
}
segs.forEach(function (seg) {
seg.addEventListener("click", function () {
selectVariant(seg.dataset.variant, true);
});
});
// Arrow-key navigation across the segmented control
grid &&
document
.querySelector(".segmented")
.addEventListener("keydown", function (e) {
if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
var idx = segs.indexOf(document.activeElement);
if (idx === -1) return;
e.preventDefault();
var next =
e.key === "ArrowRight"
? (idx + 1) % segs.length
: (idx - 1 + segs.length) % segs.length;
segs[next].focus();
selectVariant(segs[next].dataset.variant, false);
});
/* ---------- Initial paint: run the load once ---------- */
// start in loading state so first impression shows the skeletons
skeletonShow(true);
resetReveal();
setStatus("loading", "Loading all primitives…");
later(function () {
skeletonShow(false);
runReveal();
setStatus("idle", "Content loaded — replay any primitive above.");
}, 1300);
})();<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Loading States — Skeleton + spinner + progressive load set</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="page">
<header class="masthead">
<div class="masthead__lead">
<span class="eyebrow">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>
Loading primitives
</span>
<h1>Loading State Gallery</h1>
<p class="masthead__sub">Skeletons, spinners, determinate progress and a staggered content reveal — every primitive shown side by side. Hit <strong>Reload</strong> to replay the full loading → loaded sequence.</p>
</div>
<div class="masthead__controls">
<div class="segmented" role="tablist" aria-label="Highlight a loading variant">
<button class="seg" role="tab" aria-selected="true" data-variant="all">All</button>
<button class="seg" role="tab" aria-selected="false" data-variant="skeleton">Skeleton</button>
<button class="seg" role="tab" aria-selected="false" data-variant="spinner">Spinner</button>
<button class="seg" role="tab" aria-selected="false" data-variant="progress">Progress</button>
<button class="seg" role="tab" aria-selected="false" data-variant="reveal">Reveal</button>
</div>
<button class="btn btn--primary" id="reloadBtn" type="button">
<svg class="btn__icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 21v-5h5"/></svg>
<span class="btn__label">Reload all</span>
</button>
</div>
</header>
<div class="status-line">
<span class="dot" id="statusDot" data-state="idle" aria-hidden="true"></span>
<span id="statusText" aria-live="polite">Content loaded — replay any primitive above.</span>
</div>
<main class="grid" id="gallery">
<!-- SKELETON: list -->
<section class="panel" data-variant="skeleton" aria-labelledby="sk-list-h">
<div class="panel__head">
<h2 id="sk-list-h">Skeleton · List</h2>
<span class="tag tag--brand">3 rows</span>
</div>
<div class="panel__body" data-stage>
<div class="skel-state" data-loading>
<div class="sk-row" aria-hidden="true">
<span class="sk sk-avatar"></span>
<span class="sk-lines"><span class="sk sk-line w-70"></span><span class="sk sk-line w-40"></span></span>
</div>
<div class="sk-row" aria-hidden="true">
<span class="sk sk-avatar"></span>
<span class="sk-lines"><span class="sk sk-line w-60"></span><span class="sk sk-line w-50"></span></span>
</div>
<div class="sk-row" aria-hidden="true">
<span class="sk sk-avatar"></span>
<span class="sk-lines"><span class="sk sk-line w-80"></span><span class="sk sk-line w-30"></span></span>
</div>
</div>
<ul class="real-list" data-loaded hidden>
<li><span class="ava ava--violet">AM</span><span class="real-lines"><strong>Amara Okonjo</strong><small>Pushed 4 commits to <em>core-api</em></small></span><span class="tag tag--ok">live</span></li>
<li><span class="ava ava--teal">DB</span><span class="real-lines"><strong>Devon Brooks</strong><small>Opened PR #218 · pricing tiers</small></span><span class="tag tag--warn">review</span></li>
<li><span class="ava ava--amber">NK</span><span class="real-lines"><strong>Noor Kassem</strong><small>Resolved 2 incidents in <em>edge</em></small></span><span class="tag tag--ok">live</span></li>
</ul>
</div>
</section>
<!-- SKELETON: profile -->
<section class="panel" data-variant="skeleton" aria-labelledby="sk-prof-h">
<div class="panel__head">
<h2 id="sk-prof-h">Skeleton · Profile</h2>
<span class="tag tag--brand">card</span>
</div>
<div class="panel__body" data-stage>
<div class="skel-state" data-loading>
<div class="sk-profile" aria-hidden="true">
<span class="sk sk-cover"></span>
<span class="sk sk-portrait"></span>
<span class="sk sk-line w-50 center"></span>
<span class="sk sk-line w-70 center"></span>
<span class="sk-chips"><span class="sk sk-chip"></span><span class="sk sk-chip"></span><span class="sk sk-chip"></span></span>
</div>
</div>
<div class="real-profile" data-loaded hidden>
<div class="cover" aria-hidden="true"></div>
<span class="portrait">PV</span>
<h3>Priya Venkat</h3>
<p class="role">Staff Product Designer · Lisbon</p>
<div class="chips">
<span class="chip">Design Systems</span>
<span class="chip">Prototyping</span>
<span class="chip">A11y</span>
</div>
</div>
</div>
</section>
<!-- SKELETON: table rows -->
<section class="panel panel--wide" data-variant="skeleton" aria-labelledby="sk-tbl-h">
<div class="panel__head">
<h2 id="sk-tbl-h">Skeleton · Table rows</h2>
<span class="tag tag--brand">4 rows</span>
</div>
<div class="panel__body" data-stage>
<div class="skel-state" data-loading>
<table class="sk-table" aria-hidden="true">
<thead><tr><th>Invoice</th><th>Client</th><th>Amount</th><th>Status</th></tr></thead>
<tbody>
<tr><td><span class="sk sk-line w-60"></span></td><td><span class="sk sk-line w-80"></span></td><td><span class="sk sk-line w-40"></span></td><td><span class="sk sk-pill"></span></td></tr>
<tr><td><span class="sk sk-line w-50"></span></td><td><span class="sk sk-line w-70"></span></td><td><span class="sk sk-line w-50"></span></td><td><span class="sk sk-pill"></span></td></tr>
<tr><td><span class="sk sk-line w-70"></span></td><td><span class="sk sk-line w-60"></span></td><td><span class="sk sk-line w-40"></span></td><td><span class="sk sk-pill"></span></td></tr>
<tr><td><span class="sk sk-line w-50"></span></td><td><span class="sk sk-line w-80"></span></td><td><span class="sk sk-line w-50"></span></td><td><span class="sk sk-pill"></span></td></tr>
</tbody>
</table>
</div>
<table class="real-table" data-loaded hidden>
<thead><tr><th>Invoice</th><th>Client</th><th>Amount</th><th>Status</th></tr></thead>
<tbody>
<tr><td>INV-2041</td><td>Northwind Labs</td><td>$4,200</td><td><span class="tag tag--ok">Paid</span></td></tr>
<tr><td>INV-2042</td><td>Helio Studio</td><td>$1,850</td><td><span class="tag tag--warn">Pending</span></td></tr>
<tr><td>INV-2043</td><td>Quartz Freight</td><td>$9,640</td><td><span class="tag tag--ok">Paid</span></td></tr>
<tr><td>INV-2044</td><td>Mendel & Co.</td><td>$720</td><td><span class="tag tag--danger">Overdue</span></td></tr>
</tbody>
</table>
</div>
</section>
<!-- SPINNER -->
<section class="panel" data-variant="spinner" aria-labelledby="sp-h">
<div class="panel__head">
<h2 id="sp-h">Spinner · Button</h2>
<span class="tag tag--brand">inline</span>
</div>
<div class="panel__body panel__body--center" data-stage>
<div class="spinner-demo">
<p class="hint">Submit a payout — the button enters a pending state, then resolves.</p>
<button class="btn btn--accent action-btn" id="spinnerBtn" type="button">
<span class="spinner" aria-hidden="true"></span>
<span class="action-btn__label">Send payout</span>
</button>
<p class="result" id="spinnerResult" aria-live="polite" hidden>
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>
Payout of $2,310 confirmed
</p>
</div>
</div>
</section>
<!-- PROGRESS BAR -->
<section class="panel" data-variant="progress" aria-labelledby="pg-h">
<div class="panel__head">
<h2 id="pg-h">Progress · Determinate</h2>
<span class="tag tag--brand">upload</span>
</div>
<div class="panel__body" data-stage>
<div class="progress-demo">
<div class="progress-top">
<span class="file">
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg>
quarterly-report.pdf
</span>
<span class="pct" id="progressPct">0%</span>
</div>
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-label="Upload progress" id="progressBar">
<span class="progress__fill" id="progressFill"></span>
</div>
<p class="progress-meta" id="progressMeta" aria-live="polite">Waiting to start…</p>
</div>
</div>
</section>
<!-- PROGRESSIVE REVEAL -->
<section class="panel panel--wide" data-variant="reveal" aria-labelledby="rv-h">
<div class="panel__head">
<h2 id="rv-h">Progressive · Staggered reveal</h2>
<span class="tag tag--brand">4 tiles</span>
</div>
<div class="panel__body" data-stage>
<div class="reveal-grid" id="revealGrid">
<article class="tile" data-reveal style="--i:0">
<span class="tile__kpi">2,481</span>
<span class="tile__label">Active sessions</span>
<span class="tile__delta up">+12.4%</span>
</article>
<article class="tile" data-reveal style="--i:1">
<span class="tile__kpi">$38.9k</span>
<span class="tile__label">MRR this month</span>
<span class="tile__delta up">+4.1%</span>
</article>
<article class="tile" data-reveal style="--i:2">
<span class="tile__kpi">312ms</span>
<span class="tile__label">p95 latency</span>
<span class="tile__delta down">-8.0%</span>
</article>
<article class="tile" data-reveal style="--i:3">
<span class="tile__kpi">99.98%</span>
<span class="tile__label">Uptime · 30d</span>
<span class="tile__delta flat">stable</span>
</article>
</div>
</div>
</section>
</main>
</div>
<div class="toast-wrap" id="toastWrap" aria-live="polite" aria-atomic="true"></div>
<script src="script.js"></script>
</body>
</html>Skeleton + spinner + progressive load set
A compact reference board that puts every common loading primitive in one place so you can compare the feel of each pattern. The grid shows shimmering skeletons (a list with avatars, a profile card, and a four-row table), an inline spinner button that toggles a pending state before resolving, a determinate progress bar that animates an upload to 100% with a live percentage, and a progressive reveal of KPI tiles that stagger in one after another.
A segmented control at the top acts as a variant switcher: pick Skeleton, Spinner, Progress, or Reveal to dim the rest of the board, spotlight that primitive, and replay it in isolation — or choose All to see the full set together. The Reload button replays the entire loading → loaded choreography across every panel at once, driving an aria-live status line and a small toast so screen readers and sighted users both get feedback.
Everything is vanilla HTML, CSS, and JavaScript with no dependencies. The shimmer is a single animated gradient, the spinner and progress bar are pure CSS plus a tiny interval, and the reveal uses staggered timers. Motion respects prefers-reduced-motion, the segmented control is arrow-key navigable, and timers are tracked so repeated reloads cancel cleanly without overlapping animations.