All effectsLoading & feedback

Skeleton Shimmer

骨架屏扫光

A band of light sweeps across placeholder shapes while the content is loading.

Play the loading preview

Where to use it

Reserve space for content that is still loading, such as feed items or cards. Match the main shapes and spacing of the final view when you already know its layout.

Practical example

A recipe feed reserves the photo, title, and cooking-time positions for each card. A faint sweep passes over those shapes until the recipes arrive and fill their slots.

Also called

  • Shimmer Loading

AI prompt

Add Skeleton Shimmer while [target content] loads. Match the approximate size of the eventual layout and sweep a low-contrast highlight across the placeholder shapes. Expose a single meaningful loading state to assistive technology and replace the skeleton with real content when ready. Use static placeholders with reduced motion.

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 Shimmer</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;
    }

    .skeleton {
      width: min(100%, 242px);
      padding: 16px;
      border: 1px solid #4a4366;
      border-radius: 16px;
      background: #252139;
    }
    .skeleton-heading { display: flex; align-items: center; gap: 10px; }
    .heading-lines, .skeleton-lines { display: grid; gap: 7px; }
    .heading-lines { flex: 1; }
    .skeleton-lines { margin-top: 15px; }
    .placeholder {
      display: block;
      background: #413955 linear-gradient(105deg, transparent 27%, #8d7fb0 48%, transparent 69%) no-repeat;
      background-size: 280px 100%;
      background-position: -280px center;
      border-radius: 5px;
      animation: shimmer 1.65s ease-in-out infinite;
    }
    .avatar { width: 36px; height: 36px; border-radius: 50%; }
    .title-line { width: 75%; height: 8px; }
    .meta-line { width: 48%; height: 6px; }
    .body-line { height: 6px; }
    .body-line.short { width: 70%; }
    @keyframes shimmer {
      0% { background-position: -280px center; }
      82%, 100% { background-position: 220px center; }
    }

    .loop-example {
      display: grid;
      gap: 12px;
      justify-items: center;
      width: min(100%, 290px);
    }
    .loop-example [data-motion] { animation-play-state: paused; }
    .loop-example[data-playing] [data-motion] { animation-play-state: running; }
    @media (prefers-reduced-motion: reduce) {
      .loop-example [data-motion] { animation: none; }
      .loop-example [data-loop-toggle] { display: none; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="loop-example">
      <section class="skeleton" aria-label="Loading profile" aria-busy="true">
        <div class="skeleton-heading" aria-hidden="true">
          <span class="placeholder avatar" data-motion></span>
          <div class="heading-lines">
            <span class="placeholder title-line" data-motion></span>
            <span class="placeholder meta-line" data-motion></span>
          </div>
        </div>
        <div class="skeleton-lines" aria-hidden="true">
          <span class="placeholder body-line" data-motion></span>
          <span class="placeholder body-line short" data-motion></span>
        </div>
      </section>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">Play demo</button>
    </div>
  </main>
  <script>
    const example = document.querySelector('.loop-example');
    const toggle = example.querySelector('[data-loop-toggle]');

    toggle.addEventListener('click', () => {
      const playing = example.toggleAttribute('data-playing');
      toggle.textContent = playing ? "Pause demo" : "Play demo";
    });
  </script>
</body>
</html>

Original example by UI Skills