Back to the library

Shimmer skeleton

A loading placeholder card — avatar, two lines, a block — with a single highlight sweeping across the whole card rather than one gradient per shape. That is what makes it read as light crossing a surface instead of several unrelated bars flickering. Linear timing, because a sweep that eases looks like it is hesitating mid-pass.

loading

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>Shimmer skeleton</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;
        --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. */
        --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)
        );

        /* The placeholder wash: a shade between oat and ivory, and the only
           colour in the piece that is neither a neutral nor an accent. */
        --_wash: #f0eee6;

        /* Clock — every duration in the document runs off --t. The calmer
           reduced-motion breath divides by the same --speed. */
        --cycle: 1.4s;
        --t: calc(var(--cycle) / var(--speed));
        --_calm: calc(1.8s / var(--speed));
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
        color: var(--slate);
      }

      .card {
        position: relative;
        width: min(320px, calc(100% - 24px));
        padding: 20px;
        border-radius: calc(14px * var(--round));
        border: 1.5px solid var(--oat);
        background: var(--paper);
        overflow: hidden;
      }

      .row {
        display: flex;
        align-items: center;
        gap: 14px;
      }

      .avatar {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--_wash);
        flex: none;
      }

      .lines {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 9px;
      }

      .line {
        height: 10px;
        border-radius: 5px;
        background: var(--_wash);
      }

      .line.short {
        width: 55%;
      }

      .block {
        margin-top: 18px;
        height: 76px;
        border-radius: calc(10px * var(--round));
        background: var(--_wash);
      }

      /* One sweep for the whole card rather than a gradient per block: the
         highlight reads as light crossing a surface, which is why it holds
         together. Constant motion, so linear — easing would make the pass
         look like it hesitates in the middle. Only transform animates. */
      .card::after {
        content: '';
        position: absolute;
        inset: 0 auto 0 0;
        width: 60%;
        background: linear-gradient(
          90deg,
          rgba(255, 255, 255, 0) 0%,
          color-mix(in srgb, var(--paper) 85%, transparent) 50%,
          rgba(255, 255, 255, 0) 100%
        );
        animation: sweep var(--t) linear infinite;
      }

      @keyframes sweep {
        from {
          transform: translateX(-100%);
        }
        to {
          transform: translateX(266%);
        }
      }

      /* Reduced motion keeps the "not ready yet" signal but drops the travel. */
      @media (prefers-reduced-motion: reduce) {
        .card::after {
          display: none;
        }

        .avatar,
        .line,
        .block {
          animation: breathe var(--_calm) ease infinite;
        }

        @keyframes breathe {
          0%,
          100% {
            opacity: 1;
          }
          50% {
            opacity: 0.55;
          }
        }
      }
    </style>
  </head>
  <body>
    <div class="card" role="status" aria-label="Loading">
      <div class="row">
        <div class="avatar"></div>
        <div class="lines">
          <div class="line"></div>
          <div class="line short"></div>
        </div>
      </div>
      <div class="block"></div>
    </div>
  </body>
</html>