Back to the library

Wizard — a choice drops a step

Variant: Branch skip

A branching form whose first answer makes a later step irrelevant. Pick "Just me" and the team step leaves the rail at once: the rail answers the choice, not the Next button, so the cost of a choice is visible while it is still a choice. Exit first, re-layout second — the dropped stop shrinks out where it stands in 160ms on an ease-out, and only then do the others redistribute over 320ms ease-in-out, so nothing slides across a dot that is still leaving. The rail re-spaces from thirds to halves rather than shortening; its ends do not move, because the form did not get smaller, it got fewer. "1 of 4" turns over to 3 as the ranks finish closing, the old digit out before the new one in, on tabular figures so nothing shifts. Then Next is an ordinary advance. Under reduced motion the stop fades without shrinking and the middle stop keeps its short slide, because that move is the information.

transitionprogresslayoutcountercontrolloop

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>Wizard — a choice drops a step</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)
        );

        /* Clock — 6.4s: choose, the rail re-plans, a pause to read it, Next,
           reset. 1% is 64ms. The dropped step leaves in 2.5% (160ms), the
           rest close ranks in 5% (320ms), the advance is 5% (320ms). */
        --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);

        /* Four stops share the rail in thirds; three share it in halves. */
        --_third: calc(100cqw / 3);
        --_half: calc(100cqw / 2);
        --_off: calc(100% + 16px);
        --_rise: 5px;
      }

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

      .frame {
        width: clamp(232px, 82vw, 300px);
        padding: 14px;
        display: grid;
        gap: 12px;
        border-radius: calc(12px * var(--round));
        background: var(--paper);
        border: 1px solid color-mix(in srgb, var(--slate) 10%, transparent);
      }

      .body {
        display: grid;
        gap: 12px;
        animation: reset var(--t) infinite;
      }

      /* ── The rail ─────────────────────────────────────────────────────── */

      .rail {
        position: relative;
        height: 20px;
        margin: 0 10px;
        container-type: inline-size;
      }

      .track,
      .fill {
        position: absolute;
        left: 0;
        right: 0;
        top: 9px;
        height: 2px;
        border-radius: 1px;
        background: var(--oat);
      }

      .fill {
        background: var(--clay);
        transform-origin: left center;
        transform: scaleX(0);
        animation: fill var(--t) infinite;
      }

      .ring {
        position: absolute;
        left: -10px;
        top: 0;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        border: 2px solid var(--clay);
        background: var(--paper);
        animation: ring var(--t) infinite;
      }

      .dot {
        position: absolute;
        left: -6px;
        top: 4px;
        width: 12px;
        height: 12px;
        display: grid;
        place-items: center;
        border-radius: 50%;
        background: var(--paper);
        border: 2px solid var(--oat);
        color: var(--paper);
      }

      .dot svg {
        width: 8px;
        height: 8px;
      }

      .d1 {
        border-color: var(--clay);
        animation: done-1 var(--t) infinite;
      }
      .d1 svg {
        opacity: 0;
        animation: tick-1 var(--t) infinite;
      }
      .d2 {
        transform: translateX(var(--_third));
        animation: d2 var(--t) infinite;
      }
      .d3 {
        transform: translateX(calc(2 * var(--_third)));
        animation: drop var(--t) infinite;
      }
      .d4 {
        transform: translateX(100cqw);
      }

      /* ── The panels ───────────────────────────────────────────────────── */

      .stage {
        position: relative;
        height: 96px;
        overflow: hidden;
      }

      .panel {
        position: absolute;
        inset: 0;
        display: grid;
        gap: 8px;
        align-content: start;
      }

      .p1 {
        animation: p1 var(--t) infinite;
      }
      .p2 {
        gap: 7px;
        transform: translateX(var(--_off));
        animation: p2 var(--t) infinite;
      }

      .h {
        font-size: 13px;
        font-weight: 600;
        letter-spacing: -0.01em;
        margin-bottom: 2px;
      }

      .choices {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
      }

      .card {
        height: 52px;
        padding: 0 10px;
        display: grid;
        align-content: center;
        gap: 6px;
        border-radius: calc(8px * var(--round));
        border: 1px solid var(--oat);
        font-size: 12px;
        font-weight: 600;
      }

      .card i {
        display: block;
        width: 62%;
        height: 5px;
        border-radius: 3px;
        background: var(--oat);
      }

      .solo {
        animation:
          choose var(--t) infinite,
          tap var(--t) infinite;
      }

      .input {
        height: 24px;
        border-radius: calc(6px * var(--round));
        border: 1px solid var(--oat);
        display: flex;
        align-items: center;
        padding: 0 8px;
      }

      .input i {
        display: block;
        height: 6px;
        border-radius: 3px;
        background: color-mix(in srgb, var(--slate) 22%, transparent);
      }

      /* ── Footer ───────────────────────────────────────────────────────── */

      .foot {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .count {
        display: flex;
        align-items: baseline;
        gap: 0.28em;
        font-size: 12px;
        font-weight: 500;
        font-variant-numeric: tabular-nums;
        color: color-mix(in srgb, var(--slate) 58%, transparent);
      }

      /* Each figure is a two-row slot: the outgoing digit lifts out as the
         incoming one lifts in, overlapping by nothing — sequenced, not
         crossfaded, so no frame shows "3" and "4" on top of each other. */
      .slot {
        position: relative;
        display: inline-grid;
        width: 1ch;
        overflow: hidden;
      }

      .slot span {
        grid-area: 1 / 1;
      }

      .slot .now {
        animation: digit-out var(--t) infinite;
      }
      .slot .then {
        opacity: 0;
        transform: translateY(var(--_rise));
        animation: digit-in var(--t) infinite;
      }
      .cur .now {
        animation-name: digit-out-late;
      }
      .cur .then {
        animation-name: digit-in-late;
      }

      .btn {
        height: 28px;
        padding: 0 14px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
      }

      .next {
        background: var(--clay-d);
        color: var(--paper);
        animation: press var(--t) infinite;
      }

      /* ── Keyframes ────────────────────────────────────────────────────── */

      /* The rail answers the choice, not the Next button. The moment "Just
         me" is picked, the team step is gone from the plan — so the cost of a
         choice is visible while it is still a choice, and the count on Next
         never surprises anyone. */
      @keyframes choose {
        0%,
        8% {
          border-color: var(--oat);
          background: var(--paper);
          animation-timing-function: ease;
        }
        10%,
        85% {
          border-color: var(--clay);
          background: color-mix(in srgb, var(--clay) 9%, var(--paper));
        }
        86%,
        100% {
          border-color: var(--oat);
          background: var(--paper);
        }
      }

      @keyframes tap {
        0%,
        6.9% {
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        8.5% {
          transform: scale(0.97);
          animation-timing-function: var(--ease-out);
        }
        11%,
        100% {
          transform: scale(1);
        }
      }

      /* Exit first, re-layout second. The dropped stop shrinks out in 160ms
         where it stands; only once it has gone do its neighbours redistribute,
         so nothing slides across a dot that is still leaving. */
      @keyframes drop {
        0%,
        11% {
          opacity: 1;
          transform: translateX(calc(2 * var(--_third))) scale(1);
          animation-timing-function: var(--ease-out);
        }
        13.5%,
        85% {
          opacity: 0;
          transform: translateX(calc(2 * var(--_third))) scale(0.4);
        }
        86%,
        100% {
          opacity: 1;
          transform: translateX(calc(2 * var(--_third))) scale(1);
        }
      }

      /* Thirds to halves. The ends are fixed — first step, review — so only
         the middle stop actually travels; the rail re-spaces rather than
         shortens, because the form didn't get smaller, it got fewer. */
      @keyframes d2 {
        0%,
        13.5% {
          transform: translateX(var(--_third));
          border-color: var(--oat);
          animation-timing-function: var(--ease-in-out);
        }
        18.5%,
        41.5% {
          transform: translateX(var(--_half));
          border-color: var(--oat);
          animation-timing-function: ease;
        }
        43.5%,
        85% {
          transform: translateX(var(--_half));
          border-color: var(--clay);
        }
        86%,
        100% {
          transform: translateX(var(--_third));
          border-color: var(--oat);
        }
      }

      @keyframes fill {
        0%,
        41.5% {
          transform: scaleX(0);
          animation-timing-function: var(--ease-in-out);
        }
        46.5%,
        85% {
          transform: scaleX(0.5);
        }
        86%,
        100% {
          transform: scaleX(0);
        }
      }

      @keyframes ring {
        0%,
        41.5% {
          transform: translateX(0);
          animation-timing-function: var(--ease-in-out);
        }
        46.5%,
        85% {
          transform: translateX(var(--_half));
        }
        86%,
        100% {
          transform: translateX(0);
        }
      }

      @keyframes p1 {
        0%,
        41.5% {
          transform: translateX(0);
          animation-timing-function: var(--ease-in-out);
        }
        46.5%,
        85% {
          transform: translateX(calc(-1 * var(--_off)));
        }
        86%,
        100% {
          transform: translateX(0);
        }
      }

      @keyframes p2 {
        0%,
        41.5% {
          transform: translateX(var(--_off));
          animation-timing-function: var(--ease-in-out);
        }
        46.5%,
        85% {
          transform: translateX(0);
        }
        86%,
        100% {
          transform: translateX(var(--_off));
        }
      }

      @keyframes done-1 {
        0%,
        41.5% {
          background: var(--paper);
          animation-timing-function: ease;
        }
        43.5%,
        85% {
          background: var(--clay);
        }
        86%,
        100% {
          background: var(--paper);
        }
      }

      @keyframes tick-1 {
        0%,
        41.5% {
          opacity: 0;
          transform: scale(0.6);
          animation-timing-function: var(--ease-out);
        }
        44%,
        85% {
          opacity: 1;
          transform: scale(1);
        }
        86%,
        100% {
          opacity: 0;
          transform: scale(0.6);
        }
      }

      /* The total turns over as the ranks finish closing — when the rail
         visibly has three stops, not when the dot starts to leave. */
      @keyframes digit-out {
        0%,
        16% {
          opacity: 1;
          transform: translateY(0);
          animation-timing-function: var(--ease-out);
        }
        17.5%,
        85% {
          opacity: 0;
          transform: translateY(calc(-1 * var(--_rise)));
        }
        86%,
        100% {
          opacity: 1;
          transform: translateY(0);
        }
      }

      @keyframes digit-in {
        0%,
        17.5% {
          opacity: 0;
          transform: translateY(var(--_rise));
          animation-timing-function: var(--ease-out);
        }
        20%,
        85% {
          opacity: 1;
          transform: translateY(0);
        }
        86%,
        100% {
          opacity: 0;
          transform: translateY(var(--_rise));
        }
      }

      @keyframes digit-out-late {
        0%,
        44% {
          opacity: 1;
          transform: translateY(0);
          animation-timing-function: var(--ease-out);
        }
        45%,
        85% {
          opacity: 0;
          transform: translateY(calc(-1 * var(--_rise)));
        }
        86%,
        100% {
          opacity: 1;
          transform: translateY(0);
        }
      }

      @keyframes digit-in-late {
        0%,
        45% {
          opacity: 0;
          transform: translateY(var(--_rise));
          animation-timing-function: var(--ease-out);
        }
        47%,
        85% {
          opacity: 1;
          transform: translateY(0);
        }
        86%,
        100% {
          opacity: 0;
          transform: translateY(var(--_rise));
        }
      }

      @keyframes press {
        0%,
        39.9% {
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        41.5% {
          transform: scale(0.96);
          animation-timing-function: var(--ease-out);
        }
        44%,
        100% {
          transform: scale(1);
        }
      }

      @keyframes reset {
        0%,
        81% {
          opacity: 1;
          animation-timing-function: ease;
        }
        84.5%,
        86.5% {
          opacity: 0;
          animation-timing-function: ease;
        }
        91%,
        100% {
          opacity: 1;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The dropped stop fades without shrinking; the middle stop keeps its
           40px slide, the same reasoning that keeps the ring's one-gap move in
           the other wizards — it is small, and it is the information. Digits
           swap without lifting, panels fade out and then in. The cycle runs
           1.5x. */
        :root {
          --_rise: 0px;
        }

        .body,
        .fill,
        .ring,
        .d1,
        .d1 svg,
        .d2,
        .d3,
        .p1,
        .p2,
        .solo,
        .slot .now,
        .slot .then,
        .next {
          animation-duration: calc(var(--t) * 1.5);
        }

        .d3 {
          animation-name: drop-rm;
        }
        .p1 {
          animation-name: f1;
        }
        .p2 {
          animation-name: f2;
          transform: none;
          opacity: 0;
        }

        @keyframes drop-rm {
          0%,
          11% {
            opacity: 1;
            transform: translateX(calc(2 * var(--_third)));
            animation-timing-function: ease;
          }
          13.5%,
          85% {
            opacity: 0;
            transform: translateX(calc(2 * var(--_third)));
          }
          86%,
          100% {
            opacity: 1;
            transform: translateX(calc(2 * var(--_third)));
          }
        }

        /* Out, then in — never both on the same frame. */
        @keyframes f1 {
          0%,
          41.5% {
            opacity: 1;
            transform: none;
            animation-timing-function: ease;
          }
          43.5%,
          85% {
            opacity: 0;
            transform: none;
          }
          86%,
          100% {
            opacity: 1;
            transform: none;
          }
        }

        @keyframes f2 {
          0%,
          43.5% {
            opacity: 0;
            transform: none;
            animation-timing-function: var(--ease-out);
          }
          46.5%,
          85% {
            opacity: 1;
            transform: none;
          }
          86%,
          100% {
            opacity: 0;
            transform: none;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="frame"
      role="img"
      aria-label="A four-step form whose first question is who it is for: picking Just me removes the team step from the progress rail, the remaining stops spread out, the count changes from 1 of 4 to 1 of 3, and Next advances to the details step"
    >
      <div class="body">
        <div class="rail" aria-hidden="true">
          <span class="track"></span>
          <span class="fill"></span>
          <span class="ring"></span>
          <span class="dot d1"
            ><svg viewBox="0 0 12 12" fill="none">
              <path
                d="M2.5 6.2 5 8.5l4.5-5"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
              /></svg
          ></span>
          <span class="dot d2"></span>
          <span class="dot d3"></span>
          <span class="dot d4"></span>
        </div>

        <div class="stage">
          <div class="panel p1">
            <p class="h">Who is it for?</p>
            <div class="choices">
              <span class="card solo">Just me<i></i></span>
              <span class="card">A team<i></i></span>
            </div>
          </div>
          <div class="panel p2">
            <p class="h">Your details</p>
            <span class="input"><i style="width: 46%"></i></span>
            <span class="input"><i style="width: 64%"></i></span>
          </div>
        </div>

        <div class="foot">
          <span class="count" aria-hidden="true">
            <span class="slot cur"><span class="now">1</span><span class="then">2</span></span>
            <span>of</span>
            <span class="slot"><span class="now">4</span><span class="then">3</span></span>
          </span>
          <span class="btn next">Next</span>
        </div>
      </div>
    </div>
  </body>
</html>

The variant family

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