Back to the library

Still life — glance

Variant: Glance

Eyes lead and the head follows. The pupils jump in 96ms on a hard ease-out and hold — eyes do not glide, and a pupil that tweens across the white reads as drifting rather than looking — then 120ms later the face sets off after them, 560ms on ease-in-out, because a head is heavy and already on screen. The pupils live inside the face, so their keyframes are the gaze minus wherever the face has got to: as it arrives they rotate back toward centre by exactly as much, on exactly the same curve, and the point being looked at never moves. That is the vestibulo-ocular reflex, and without it the figure looks past its target. Two smaller touches sell a turn only a couple of pixels wide: the beak travels 60% further than the eyes, a parallax that makes the face turn on the body instead of sliding across it, and the long right-to-left jump starts inside a blink, the way animators — and people — hide a big saccade. Reach for it on a character that should seem to notice the interface: an assistant beside a form, a mascot in an empty state. Under reduced motion the face stays put and the pupils change position only while a blink has the eye shut.

ambientidlecharactereasingstaggersvgloop

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>Still life — glance</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 — look right, look left, look back, holding about two seconds
           on each. Gaze is a series of rests joined by jumps; the holds are the
           look, the jumps only get there. */
        --cycle: 6.4s;
        --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);
      }

      figure {
        display: grid;
        justify-items: center;
        gap: clamp(6px, 2vh, 12px);
      }

      /* Sized off the frame's height as well as its width: the card is short and
         the caption has to fit under the figure at every stage. */
      svg {
        display: block;
        width: min(260px, 84vw, calc((100vh - 76px) * 1.4));
        height: auto;
        overflow: visible;
      }

      .perch {
        fill: none;
        stroke: color-mix(in oklch, var(--oat), var(--slate) 26%);
        stroke-width: 4;
        stroke-linecap: round;
      }

      .twig {
        stroke-width: 2.6;
      }

      .tail,
      .beak,
      .wing {
        fill: var(--clay-d);
      }

      .body {
        fill: var(--clay);
      }

      .belly {
        fill: color-mix(in oklch, var(--clay) 34%, var(--ivory));
      }

      .foot,
      .lid {
        fill: none;
        stroke: var(--clay-d);
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
      }

      .lid {
        stroke-width: 2.4;
        opacity: 0;
      }

      .white {
        fill: var(--paper);
      }

      .pupil {
        fill: var(--slate);
      }

      /* Every pivot is a point on the drawing rather than a box's centre: the
         body grows and leans from its feet, the face counter-turns about them
         too, the tail swings from where it meets the body, and the eyes close
         about their own centre line. */
      .fig,
      .ride,
      .breath,
      .head {
        transform-origin: 100px 125px;
      }

      .belly {
        transform-origin: 100px 121px;
      }

      .tail {
        transform-origin: 100px 118px;
      }

      .eyes {
        transform-origin: 100px 80px;
      }

      figcaption {
        display: grid;
        justify-items: center;
        gap: 2px;
        text-align: center;
      }

      .cue {
        font-size: clamp(13px, 3.8vw, 15px);
        font-weight: 600;
        letter-spacing: -0.01em;
      }

      .spec {
        font-size: clamp(11.5px, 3.2vw, 12.5px);
        font-variant-numeric: tabular-nums;
        color: color-mix(in oklch, var(--slate) 58%, var(--ivory));
      }

      /* Eyes lead, the head follows. The pupils jump in 96ms on a hard ease-out.
         Eyes do not glide, and a pupil that tweens across the white reads as
         drifting, not looking. Then 120ms later the face sets off after them,
         taking 560ms on ease-in-out, because a head is heavy and already on screen. */
      .head {
        animation: turn var(--t) infinite;
      }

      /* The pupils sit inside the face, so their keyframes are the gaze minus
         wherever the face has got to. As the face arrives they rotate back
         toward centre by the same amount, on the same curve, and the point
         being looked at never moves — the vestibulo-ocular reflex, which is
         what makes the figure look at something rather than past it. */
      .pupils {
        animation: look var(--t) infinite;
      }

      /* The beak sits nearer the viewer than the eyes, so on a turn it travels
         60% further. That parallax is what makes a short shift read as a head
         turning on a body rather than a face sliding across it. */
      .beak {
        animation: nose var(--t) infinite;
      }

      /* The long jump, right to left, starts inside a blink. Animators pair a
         big saccade with a blink, and so do people. */
      .eyes {
        animation: blink var(--t) infinite;
      }

      .lid {
        animation: lid var(--t) infinite;
      }

      @keyframes turn {
        0% {
          translate: 0 0;
        }
        11.25% {
          translate: 0px 0;
          animation-timing-function: var(--ease-in-out);
        }
        20% {
          translate: 1.5px 0;
        }
        48.75% {
          translate: 1.5px 0;
          animation-timing-function: var(--ease-in-out);
        }
        57.5% {
          translate: -1.5px 0;
        }
        80% {
          translate: -1.5px 0;
          animation-timing-function: var(--ease-in-out);
        }
        88.75% {
          translate: 0px 0;
        }
        100% {
          translate: 0px 0;
        }
      }

      @keyframes look {
        0% {
          translate: 0 0;
        }
        9.375% {
          translate: 0px 0;
          animation-timing-function: var(--ease-out);
        }
        10.875% {
          translate: 2.5px 0;
        }
        11.25% {
          translate: 2.5px 0;
          animation-timing-function: var(--ease-in-out);
        }
        20% {
          translate: 1px 0;
        }
        46.875% {
          translate: 1px 0;
          animation-timing-function: var(--ease-out);
        }
        48.375% {
          translate: -4px 0;
        }
        48.75% {
          translate: -4px 0;
          animation-timing-function: var(--ease-in-out);
        }
        57.5% {
          translate: -1px 0;
        }
        78.125% {
          translate: -1px 0;
          animation-timing-function: var(--ease-out);
        }
        79.625% {
          translate: 1.5px 0;
        }
        80% {
          translate: 1.5px 0;
          animation-timing-function: var(--ease-in-out);
        }
        88.75% {
          translate: 0px 0;
        }
        100% {
          translate: 0px 0;
        }
      }

      @keyframes nose {
        0% {
          translate: 0 0;
        }
        11.25% {
          translate: 0px 0;
          animation-timing-function: var(--ease-in-out);
        }
        20% {
          translate: 0.9px 0;
        }
        48.75% {
          translate: 0.9px 0;
          animation-timing-function: var(--ease-in-out);
        }
        57.5% {
          translate: -0.9px 0;
        }
        80% {
          translate: -0.9px 0;
          animation-timing-function: var(--ease-in-out);
        }
        88.75% {
          translate: 0px 0;
        }
        100% {
          translate: 0px 0;
        }
      }

      @keyframes blink {
        0% {
          scale: 1 1;
        }
        46.25% {
          scale: 1 1;
          animation-timing-function: linear;
        }
        47.375% {
          scale: 1 0.04;
        }
        47.938% {
          scale: 1 0.04;
          animation-timing-function: var(--ease-out);
        }
        50.562% {
          scale: 1 1;
        }
        100% {
          scale: 1 1;
        }
      }

      @keyframes lid {
        0% {
          opacity: 0;
          animation-timing-function: steps(1, end);
        }
        47% {
          opacity: 1;
          animation-timing-function: steps(1, end);
        }
        48.594% {
          opacity: 0;
          animation-timing-function: steps(1, end);
        }
        100% {
          opacity: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The face stays put and nothing travels. The pupils still change where
           they rest, which is all a glance has to say, but each change happens
           while a blink has the eye shut, on a clock twice as long. */
        .head,
        .beak {
          animation: none;
        }

        .pupils {
          animation: look-still calc(var(--t) * 2) infinite;
        }

        .eyes {
          animation: blink-still calc(var(--t) * 2) infinite;
        }

        .lid {
          animation: lid-still calc(var(--t) * 2) infinite;
        }

        @keyframes look-still {
          0% {
            translate: 0 0;
          }
          9.844% {
            translate: 0px 0;
            animation-timing-function: steps(1, end);
          }
          10.078% {
            translate: 2.5px 0;
          }
          47.344% {
            translate: 2.5px 0;
            animation-timing-function: steps(1, end);
          }
          47.578% {
            translate: -2.5px 0;
          }
          78.594% {
            translate: -2.5px 0;
            animation-timing-function: steps(1, end);
          }
          78.828% {
            translate: 0px 0;
          }
          100% {
            translate: 0px 0;
          }
        }

        @keyframes blink-still {
          0% {
            scale: 1 1;
          }
          9.375% {
            scale: 1 1;
            animation-timing-function: linear;
          }
          9.938% {
            scale: 1 0.04;
          }
          10.219% {
            scale: 1 0.04;
            animation-timing-function: var(--ease-out);
          }
          11.531% {
            scale: 1 1;
          }
          46.875% {
            scale: 1 1;
            animation-timing-function: linear;
          }
          47.438% {
            scale: 1 0.04;
          }
          47.719% {
            scale: 1 0.04;
            animation-timing-function: var(--ease-out);
          }
          49.031% {
            scale: 1 1;
          }
          78.125% {
            scale: 1 1;
            animation-timing-function: linear;
          }
          78.687% {
            scale: 1 0.04;
          }
          78.969% {
            scale: 1 0.04;
            animation-timing-function: var(--ease-out);
          }
          80.281% {
            scale: 1 1;
          }
          100% {
            scale: 1 1;
          }
        }

        @keyframes lid-still {
          0% {
            opacity: 0;
            animation-timing-function: steps(1, end);
          }
          9.75% {
            opacity: 1;
            animation-timing-function: steps(1, end);
          }
          10.547% {
            opacity: 0;
            animation-timing-function: steps(1, end);
          }
          47.25% {
            opacity: 1;
            animation-timing-function: steps(1, end);
          }
          48.047% {
            opacity: 0;
            animation-timing-function: steps(1, end);
          }
          78.5% {
            opacity: 1;
            animation-timing-function: steps(1, end);
          }
          79.297% {
            opacity: 0;
            animation-timing-function: steps(1, end);
          }
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <figure
      role="img"
      aria-label="A small round bird on a perch that glances right, then left, then back: its eyes jump first and its face turns after them"
    >
      <svg viewBox="30 46 140 104" aria-hidden="true">
        <g class="ride"><path class="tail" d="M94 116 L90 140 L100 135.5 L110 140 L106 116 Z" /></g>
        <path class="perch" d="M36 126 Q100 130 164 126" />
        <path class="perch twig" d="M146 127 L154 119.5" />
        <g class="fig">
          <path
            class="foot"
            d="M94 121 V126.5 M106 121 V126.5 M90.5 128 Q93 124.5 96.5 127 M102.5 128 Q105 124.5 108.5 127"
          />
          <g class="breath">
            <ellipse class="body" cx="100" cy="91.5" rx="30" ry="33.5" />
            <ellipse class="belly" cx="100" cy="110" rx="17" ry="11" />
            <path
              class="wing"
              d="M72.5 88 Q67 106 85 121 Q76 104 72.5 88 Z M127.5 88 Q133 106 115 121 Q124 104 127.5 88 Z"
            />
            <g class="head">
              <path class="beak" d="M96 89 H104 L100 95.5 Z" />
              <g class="eyes">
                <circle class="white" cx="89" cy="80" r="8.5" />
                <circle class="white" cx="111" cy="80" r="8.5" />
                <g class="pupils">
                  <circle class="pupil" cx="89" cy="80" r="3.4" />
                  <circle class="pupil" cx="111" cy="80" r="3.4" />
                </g>
              </g>
              <path class="lid" d="M80.5 80 Q89 81 97.5 80 M102.5 80 Q111 81 119.5 80" />
            </g>
          </g>
        </g>
      </svg>
      <figcaption>
        <span class="cue">Glance</span>
        <span class="spec">eyes 96ms · head 120ms later, 560ms</span>
      </figcaption>
    </figure>
  </body>
</html>

The variant family

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