Back to the library

Stow — fold into a summary chip

Variant: Fold to chip

A filter panel that, on Apply, becomes the chip that summarises it. It is one surface moving between two rectangles — a clip-path inset from the panel’s rect to the chip’s, radius and all — so the chip is visibly the panel, condensed, and tapping it plainly opens the same thing back up. The order is the lesson: the contents fade out in 120ms before the edge moves and return only after it lands, so nothing in the panel is ever squeezed by a clip crossing it; the chip’s label arrives last, once there is a chip for it to sit in. Folding runs 330ms on the stow curve because both ends are on screen; unfolding answers a tap, so it eases out in 270ms. The outline comes from a drop-shadow on the parent, because a clip-path clips its own element’s border too. Use it for filters, composers and any panel whose result outlives it as a summary.

transitionmorphclip-pathcontrolloop

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>Stow — fold into a summary chip</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 — 6s, so 1% is 60ms. Fold: contents out 120ms, surface 330ms,
           label in 150ms. Unfold: label out 60ms, surface 270ms, contents in. */
        --cycle: 6s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-accent: cubic-bezier(0.5, 0, 0.15, 1);

        /* The two rectangles the one surface moves between, as clip insets of
           the whole frame (100 × 66.67cqw). The chip's radius is half its
           height — a pill, so it stays literal. */
        --_panel: inset(15.5cqw 39cqw 3.17cqw 5cqw round calc(10px * var(--round)));
        --_chip: inset(3.5cqw 49cqw 54.17cqw 25cqw round 4.5cqw);
      }

      * {
        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 {
        position: relative;
        container-type: inline-size;
        width: clamp(236px, 76vw, 320px);
        aspect-ratio: 3 / 2;
        border-radius: calc(12px * var(--round));
        background: color-mix(in srgb, var(--oat) 26%, var(--paper));
        border: 1px solid color-mix(in srgb, var(--slate) 10%, transparent);
        overflow: hidden;
        font-size: 11px;
      }

      /* Above the surface, so the fold's corner tucks under the button on its
         diagonal instead of sweeping across the label. */
      .filter {
        position: absolute;
        z-index: 3;
        background: var(--paper);
        left: 5cqw;
        top: 3.5cqw;
        width: 17cqw;
        height: 9cqw;
        display: grid;
        place-items: center;
        border-radius: calc(6px * var(--round));
        border: 1px solid color-mix(in srgb, var(--slate) 16%, transparent);
        font-weight: 600;
      }

      .results {
        position: absolute;
        left: 5cqw;
        right: 5cqw;
        top: 17cqw;
        display: grid;
        gap: 2.6cqw;
      }

      .results span {
        height: 7.4cqw;
        border-radius: calc(5px * var(--round));
        background: color-mix(in srgb, var(--slate) 5%, transparent);
      }

      /* Outline and lift come from the parent's filter, because a clip-path
         also clips the element's own border and shadow. */
      .lift {
        position: absolute;
        inset: 0;
        z-index: 1;
        filter: drop-shadow(0 0 0.6px color-mix(in srgb, var(--slate) 45%, transparent))
          drop-shadow(0 4px 6px color-mix(in srgb, var(--slate) 12%, transparent));
      }

      .surface {
        position: absolute;
        inset: 0;
        background: var(--paper);
        clip-path: var(--_panel);
        animation: fold var(--t) infinite;
      }

      .contents {
        position: absolute;
        z-index: 2;
        left: 5cqw;
        top: 15.5cqw;
        width: 56cqw;
        height: 48cqw;
        display: grid;
        align-content: space-between;
        padding: 3.2cqw 3.6cqw;
      }

      .contents > * {
        animation: contents var(--t) infinite;
      }

      .head {
        font-weight: 600;
        color: color-mix(in srgb, var(--slate) 55%, transparent);
      }

      .opt {
        display: flex;
        align-items: center;
        gap: 2.4cqw;
      }

      .opt::before {
        content: '';
        flex: none;
        width: 12px;
        height: 12px;
        border-radius: calc(3px * var(--round));
        border: 1.5px solid color-mix(in srgb, var(--slate) 30%, transparent);
      }

      .opt.on::before {
        border-color: var(--clay);
        background: var(--clay);
        box-shadow: inset 0 0 0 2.5px var(--paper);
      }

      .apply {
        justify-self: end;
        padding: 3px 10px;
        border-radius: calc(6px * var(--round));
        background: var(--clay);
        color: var(--paper);
        font-weight: 600;
        animation:
          contents var(--t) infinite,
          press var(--t) infinite;
      }

      .label {
        position: absolute;
        z-index: 2;
        left: 25cqw;
        top: 3.5cqw;
        width: 26cqw;
        height: 9cqw;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1.6cqw;
        border-radius: 4.5cqw;
        font-weight: 600;
        opacity: 0;
        animation: label var(--t) infinite;
      }

      .label::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--clay);
      }

      /* One surface, two rectangles. The fold moves it in-out because both
         ends are on screen; the unfold is an answer to a tap, so it eases out
         and spends 60ms less. */
      @keyframes fold {
        0%,
        17.5% {
          clip-path: var(--_panel);
          background: var(--paper);
          animation-timing-function: var(--ease-accent);
        }
        23%,
        59% {
          clip-path: var(--_chip);
          background: var(--paper);
          animation-timing-function: var(--ease-out);
        }
        60.3% {
          clip-path: var(--_chip);
          background: color-mix(in srgb, var(--oat) 60%, var(--paper));
          animation-timing-function: var(--ease-out);
        }
        61% {
          clip-path: var(--_chip);
          animation-timing-function: var(--ease-out);
        }
        62.5% {
          background: var(--paper);
        }
        65.5%,
        100% {
          clip-path: var(--_panel);
          background: var(--paper);
        }
      }

      /* Out before the fold starts, back only after the unfold lands: nothing
         in the panel is ever squeezed by the edge moving across it. */
      @keyframes contents {
        0%,
        16% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        18%,
        65.5% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        68.5%,
        100% {
          opacity: 1;
        }
      }

      @keyframes label {
        0%,
        23% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        25.5%,
        61% {
          opacity: 1;
          animation-timing-function: var(--ease-out);
        }
        62%,
        100% {
          opacity: 0;
        }
      }

      @keyframes press {
        0%,
        14% {
          transform: scale(1);
          animation-timing-function: var(--ease-out);
        }
        15% {
          transform: scale(0.95);
          animation-timing-function: var(--ease-out);
        }
        16.5%,
        100% {
          transform: scale(1);
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* Twice as slow. The panel fades out where it is and the chip fades
           in where it is: two states, no shape travelling between them. */
        :root {
          --t: calc(var(--cycle) * 2 / var(--speed));
        }

        .apply {
          transform: none !important;
        }

        .lift {
          animation: rm-panel var(--t) infinite;
        }

        .surface {
          animation: none;
        }

        .label {
          background: var(--paper);
          box-shadow: 0 0 0 1px color-mix(in srgb, var(--slate) 22%, transparent);
        }

        @keyframes rm-panel {
          0%,
          17.5% {
            opacity: 1;
            animation-timing-function: ease;
          }
          21%,
          61% {
            opacity: 0;
            animation-timing-function: ease;
          }
          64.5%,
          100% {
            opacity: 1;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="frame"
      role="img"
      aria-label="Applying a filter panel folds the panel's surface up into a summary chip reading 2 inputs beside the Filter button; tapping the chip unfolds it back into the panel"
    >
      <span class="filter">Filter</span>
      <div class="results">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </div>
      <div class="lift"><div class="surface"></div></div>
      <div class="contents">
        <span class="head">Show inputs</span>
        <span class="opt on">Vocals</span>
        <span class="opt on">Drums</span>
        <span class="opt">Keys</span>
        <span class="apply">Apply</span>
      </div>
      <span class="label">2 inputs</span>
    </div>
  </body>
</html>

The variant family

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