Back to the library

Glyph — search

Variant: Search

A magnifier drawn as one path in one stroke — the ring starts and ends at the handle's junction and the handle carries on from there at the same pace — and then it looks. Eyes do not glide across a page; they jump and rest. So the glass makes three 128ms hops on a hard ease-out, each followed by a still look of 352ms, then a hop home. A smooth wander would read as idle drift; the stops are what make it read as looking for something. Every stop is a multiple of 1.5 units, a whole pixel in the 16px button, so the small copy stays sharp while it looks instead of blurring between pixels. Use it while a query is in flight — a search button, a command palette's empty state — drawing once on mount and looping only the hops, and swap it for results the moment they land.

svgline-drawingiconloadingloop

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>Glyph — search</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;
        --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)
        );

        /* Clock — 3.2s: one-stroke draw 512ms, three 128ms hops each followed
           by a 352ms look, a hop home, a fade. In product, draw once on mount
           and loop only the hops. */
        --cycle: 3.2s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
      }

      * {
        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);
      }

      .demo {
        display: grid;
        justify-items: center;
        gap: clamp(14px, 5vmin, 28px);
      }

      .glyph {
        display: block;
        fill: none;
        stroke: currentColor;
        stroke-linecap: round;
        stroke-linejoin: round;
      }

      /* Two instances of the same file. The hero shows what the strokes do;
         the button shows whether it still reads at the size it will ship at.
         The 16px copy takes a 2-unit stroke so it survives the pixel grid —
         at the hero's 1.5 it would render under a pixel wide. */
      .hero {
        width: clamp(72px, 30vmin, 128px);
        height: auto;
        stroke-width: 1.5;
      }

      .button {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 8px 16px 8px 13px;
        border: 1px solid var(--oat);
        border-radius: 999px;
        background: var(--paper);
        color: inherit;
        font: inherit;
        font-size: 13px;
        font-weight: 500;
        line-height: 1;
        cursor: pointer;
      }

      .button .glyph {
        width: 16px;
        height: 16px;
        stroke-width: 2;
      }

      .stroke {
        stroke-dasharray: 100 200;
        stroke-dashoffset: 100;
      }

      /* Curves sit on the element: Chromium ignores a var() timing function
         inside keyframes and falls back to plain ease. */

      /* One path, one stroke, the way a hand draws it: the ring starts and
         ends at the handle's junction and the handle carries on outward from
         there, with no change of pace at the join. */
      .stroke {
        animation: stroke var(--t) var(--ease-in-out) infinite;
      }

      .glass {
        animation: glass var(--t) var(--ease-out) infinite;
      }

      @keyframes stroke {
        0%,
        4% {
          stroke-dashoffset: 100;
        }
        20%,
        100% {
          stroke-dashoffset: 0;
        }
      }

      /* Eyes do not glide across a page; they jump and then rest. So the glass
         does the same — 128ms hops on a hard ease-out, each followed by a
         still look of 352ms. A smooth wander here would read as idle drift;
         the stops are what make it read as looking for something. Every stop
         is a multiple of 1.5 units, a whole pixel in the 16px button, so the
         small copy is sharp while it looks rather than blurred. */
      @keyframes glass {
        0%,
        22% {
          opacity: 1;
          transform: translate(0, 0);
        }
        26%,
        37% {
          transform: translate(-3px, -1.5px);
        }
        41%,
        52% {
          transform: translate(1.5px, -3px);
        }
        56%,
        67% {
          transform: translate(0, 1.5px);
        }
        71%,
        88% {
          opacity: 1;
          transform: translate(0, 0);
        }
        96%,
        100% {
          opacity: 0;
          transform: translate(0, 0);
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The hops go. The one-stroke draw and the fade stay, at half pace. */
        .stroke {
          animation-duration: calc(var(--t) * 2);
        }

        .glass {
          animation: glass-fade calc(var(--t) * 2) var(--ease-out) infinite;
        }

        @keyframes glass-fade {
          0%,
          88% {
            opacity: 1;
          }
          96%,
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div class="demo">
      <svg
        class="glyph hero"
        viewBox="0 0 24 24"
        role="img"
        aria-label="A search icon: the magnifier draws in one stroke, ring then handle, then hops between three spots, pausing at each as if reading"
      >
        <g class="glass">
          <path
            class="stroke"
            pathLength="100"
            d="M15.096 15.096 A6.5 6.5 0 0 1 5.904 5.904 A6.5 6.5 0 0 1 15.096 15.096 L20.5 20.5"
          />
        </g>
      </svg>

      <button class="button" type="button">
        <svg class="glyph" viewBox="0 0 24 24" aria-hidden="true">
          <g class="glass">
            <path
              class="stroke"
              pathLength="100"
              d="M15.096 15.096 A6.5 6.5 0 0 1 5.904 5.904 A6.5 6.5 0 0 1 15.096 15.096 L20.5 20.5"
            />
          </g>
        </svg>
        Searching
      </button>
    </div>
  </body>
</html>

The variant family

Same idea, one axis moved. Compare them side by side before you commit.