Back to the library

Still life — breath

Variant: Breath

Breath on an idle figure, done as a change in size rather than a bob: the outline grows 2.4% upward and 2% outward from the feet, so the bird stays planted on its perch — translate it and it is floating, not filling. The belly patch swells three times as much as the outline, and that difference is what the eye reads as breath; scale everything alike and the figure is only zooming. The rhythm is uneven on purpose. In takes 1.5s on a sine, because it is muscle working at an even effort; out takes 2.3s on a gentle decay, quickest at the top because the lungs are recoiling, but not the library's hard ease-out, which would empty the figure in half a second and leave the rest of the exhale looking like a pause. Then 0.6s of nothing at the bottom — the rest a pumped loop leaves out. Reach for it on empty-state mascots, onboarding characters and illustrated waiting screens, where a figure should look calm without asking to be watched. Under reduced motion only the belly keeps a small, slower swell.

ambientidlecharacterbreathingsvgloop

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 — breath</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 — one breath: in 1.5s, out 2.3s, empty for 0.6s. Out runs longer
           than in, and the rest at the bottom is the part loops leave out: a
           figure that turns straight round from exhale to inhale is being pumped,
           not breathing. */
        --cycle: 4.4s;
        --t: calc(var(--cycle) / var(--speed));

        /* Inhale is a sine, because it is muscle pulling at an even effort. */
        --ease-accent: cubic-bezier(0.37, 0, 0.63, 1);
        /* The exhale is a gentle decay — lungs recoil, so it is quickest at
           the top — but not the library's ease-out, which empties the figure in
           half a second and leaves the rest of the 2.3s looking like a pause. */
        --_ease-exhale: cubic-bezier(0.33, 0.7, 0.5, 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));
      }

      /* Breath is a size change, never a bob. The outline grows 2.4% upward
         from the feet and 2% outward, so the figure stays planted on the perch
         — translate it instead and it is floating, not filling. */
      .breath {
        animation: inhale var(--t) infinite;
      }

      /* The belly patch swells three times as much as the outline. That
         difference is what the eye reads as breath: if everything scales by the
         same amount the figure is merely zooming. */
      .belly {
        animation: fill var(--t) infinite;
      }

      @keyframes inhale {
        0% {
          scale: 1 1;
          animation-timing-function: var(--ease-accent);
        }
        34.091% {
          scale: 1.02 1.024;
          animation-timing-function: var(--_ease-exhale);
        }
        86.364% {
          scale: 1 1;
        }
        100% {
          scale: 1 1;
        }
      }

      @keyframes fill {
        0% {
          scale: 1;
          animation-timing-function: var(--ease-accent);
        }
        34.091% {
          scale: 1.07;
          animation-timing-function: var(--_ease-exhale);
        }
        86.364% {
          scale: 1;
        }
        100% {
          scale: 1;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The outline parks; the belly keeps a third of its swell on a slower
           clock, so the figure is still visibly not a picture. */
        .breath {
          animation: none;
        }

        .belly {
          animation: fill-still calc(var(--t) * 1.5) var(--ease-accent) infinite alternate;
        }

        @keyframes fill-still {
          from {
            scale: 1;
          }
          to {
            scale: 1.025;
          }
        }
      }
    </style>
  </head>
  <body>
    <figure
      role="img"
      aria-label="A small round bird on a perch, breathing: its belly swells and its outline grows slightly from its feet, then rests"
    >
      <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">Breath</span>
        <span class="spec">in 1.5s · out 2.3s · rest 0.6s</span>
      </figcaption>
    </figure>
  </body>
</html>

The variant family

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

Still life — breath - Animations