kitbash Connect agent
Components

Flavour picker

A coloured stage with a giant two-line word, a big lid sticker, two taped picture tiles, tags, a short text and a rack of small lids. Choosing a lid rolls the big one out and a new one in, changes the stage colour and resets the word. Each choice is a button with data attributes, so adding a flavour is one line.

Part of the style

Sticker Shock

7 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --lime: #ffffff;
  --paper: #ffffff;
  --pine: #040608;
  --ink: #000000;
  --shade: rgba(0, 0, 0, 0.3);
  --forest: #1a0d00;
  --sun: #b66b45;
  --kraft: #987665;
  --kraft-ink: #0d0200;
  --tape: #987d70;
  --kraft-light: #97796b;
  --note: #ac6948;
  --coral: #b1866e;
  --tangerine: #b48369;
  --sky: #a37063;
  --iris: #b7853f;
  --grape: #704905;
  --candy: #b66b45;
}
</style>

<section class="picker" id="flavours">
  <div class="picker__stage">
    <p class="picker__chip">Meet the loud ones</p>

    <div class="picker__about">
      <ul class="picker__tags">
        <li class="picker__tag">Burgers</li>
        <li class="picker__tag">Cheese boards</li>
        <li class="picker__tag">Straight from the jar</li>
      </ul>
      <p class="picker__text">Always ready for burgers, cheese boards and standing at the fridge at midnight. Crisp, garlicky, zero drama.</p>
    </div>

    <div class="picker__show">
      <p class="picker__word" aria-live="polite">
        <span class="picker__word-line">The</span>
        <span class="picker__word-line picker__word-name">Classic</span>
      </p>

      <div class="picker__tile picker__tile--jar">
        <span class="picker__tape"></span>
        <svg viewBox="0 0 200 200" aria-hidden="true">
          <path class="picker__fan" d="M0 200V150l25-18 25 18 25-18 25 18 25-18 25 18 25-18 25 18v50Z" />
          <rect class="picker__jar-glass" x="58" y="62" width="84" height="104" rx="16" />
          <rect class="picker__jar-pickle" x="70" y="78" width="16" height="78" rx="8" />
          <rect class="picker__jar-pickle" x="92" y="86" width="16" height="70" rx="8" />
          <rect class="picker__jar-pickle" x="114" y="74" width="16" height="82" rx="8" />
          <rect class="picker__jar-cap" x="52" y="42" width="96" height="26" rx="8" />
        </svg>
      </div>

      <div class="picker__lid" role="img" aria-label="Jar lid">
        <svg class="picker__lid-print" viewBox="0 0 200 200" aria-hidden="true">
          <path id="picker-lid-arc" d="M30,100 a70,70 0 1,1 140,0" fill="none" />
          <path id="picker-lid-foot" d="M5,100 a95,95 0 0,0 190,0" fill="none" />
          <text class="picker__lid-arc"><textPath href="#picker-lid-arc" startOffset="50%">Packed by hand · 400 g · keep it cold</textPath></text>
          <text class="picker__lid-foot"><textPath class="picker__lid-note" href="#picker-lid-foot" startOffset="50%">Extra loud</textPath></text>
        </svg>
        <span class="picker__lid-brand">Loud Jar</span>
        <strong class="picker__lid-name">Dill<br>Spears</strong>
        <span class="picker__lid-code"></span>
      </div>

      <div class="picker__tile picker__tile--slices">
        <span class="picker__tape"></span>
        <span class="picker__slice"></span>
        <span class="picker__slice"></span>
        <span class="picker__slice"></span>
      </div>

      <a class="picker__taste" href="#hello">Taste it</a>
    </div>

    <div class="picker__rack">
      <p class="picker__hint">pick one!</p>
      <button class="picker__pick" type="button" aria-pressed="true" style="--lid: var(--sun)"
        data-name="Dill|Spears" data-note="Extra loud" data-word="Classic" data-lid="sun" data-stage="tangerine" data-ink="sun" data-copy="paper"
        data-tags="Burgers|Cheese boards|Straight from the jar"
        data-text="Always ready for burgers, cheese boards and standing at the fridge at midnight. Crisp, garlicky, zero drama."><b>Dill<br>Spears</b></button>
      <button class="picker__pick" type="button" aria-pressed="false" style="--lid: var(--coral)"
        data-name="Kim|Chi" data-note="Properly funky" data-word="Hothead" data-lid="coral" data-stage="sky" data-ink="paper" data-copy="pine"
        data-tags="Fried rice|Toasties|Hangovers"
        data-text="Three weeks in the crock, a lifetime in your fridge door. Turns plain rice into dinner and a toastie into a personality."><b>Kim<br>chi</b></button>
      <button class="picker__pick" type="button" aria-pressed="false" style="--lid: var(--sky)"
        data-name="Bread &amp;|Butter" data-note="Sweet talker" data-word="Sweetie" data-lid="sky" data-stage="iris" data-ink="sun" data-copy="paper"
        data-tags="Sandwiches|Potato salad|Picky eaters"
        data-text="Soft on the sour, big on the snap. The one that gets children to eat a sandwich and adults to finish the jar."><b>Bread<br>&amp; Butter</b></button>
      <button class="picker__pick" type="button" aria-pressed="false" style="--lid: var(--iris)"
        data-name="Beet|Kraut" data-note="Stains everything" data-word="Showoff" data-lid="iris" data-stage="sun" data-ink="tangerine" data-copy="kraft-ink"
        data-tags="Hot dogs|Grain bowls|White shirts"
        data-text="Loud colour, louder crunch. Makes every plate look planned and every tablecloth look worried."><b>Beet<br>Kraut</b></button>
    </div>
  </div>
</section>

<style>
  .picker {
    --picker-next: var(--lime);
    --picker-stage: var(--tangerine);
    --picker-ink: var(--sun);
    --picker-copy: var(--paper);
    --picker-lid: var(--sun);
    background: var(--crease) 0 0 / var(--crease-size), var(--picker-next);
    background-blend-mode: soft-light;
    overflow: clip;
  }

  .picker__stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr) minmax(0, 1fr);
    grid-template-areas:
      "chip chip chip"
      "about show rack";
    align-items: center;
    gap: 1rem var(--gutter);
    padding: 1.5rem var(--gutter) calc(var(--curve-depth) + 2rem);
    border-radius: 0 0 50% 50% / 0 0 var(--curve-depth) var(--curve-depth);
    background: var(--crease) 0 0 / var(--crease-size), var(--picker-stage);
    background-blend-mode: soft-light;
    transition: background-color var(--time-slow) var(--ease-out);
  }

  .picker__chip,
  .picker__tag {
    width: fit-content;
    margin: 0;
    padding: 0.42rem 0.7rem 0.34rem 1.25rem;
    border-radius: var(--radius-chip);
    background:
      radial-gradient(circle, var(--kraft-ink) 1.1px, transparent 1.6px) 0.42rem 50% / 4px 5px repeat-y,
      var(--sun);
    color: var(--kraft-ink);
    font: 800 var(--size-tag) / 1 var(--font-display);
    text-transform: uppercase;
    box-shadow: 0 0.14rem 0 var(--shade);
  }

  .picker__chip {
    grid-area: chip;
    justify-self: center;
    transform: rotate(-2deg);
  }

  .picker__about {
    grid-area: about;
    align-self: end;
    position: relative;
    z-index: 3;
    padding-bottom: 4vw;
  }

  .picker__tags {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0 0 2.5rem;
    padding: 0;
    list-style: none;
  }

  .picker__tag:nth-child(odd) {
    transform: rotate(-1.5deg);
  }

  .picker__tag:nth-child(even) {
    transform: rotate(1.2deg);
  }

  .picker__text {
    max-width: 17rem;
    margin: 0;
    font-weight: 600;
    color: var(--picker-copy);
    transition: color var(--time-slow) var(--ease-out);
  }

  .picker__swap {
    animation: picker-swap var(--time-pop) var(--ease-out);
  }

  @keyframes picker-swap {
    from {
      opacity: 0;
      transform: translateY(0.6rem);
    }
  }

  /* the show: giant word, lid, two picture tiles */
  .picker__show {
    grid-area: show;
    position: relative;
    height: 43vw;
  }

  .picker__word {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    font: 900 15.5vw / 0.76 var(--font-display);
    text-transform: uppercase;
    letter-spacing: -0.015em;
    white-space: nowrap;
    color: var(--picker-ink);
    transition: color var(--time-slow) var(--ease-out);
  }

  .picker__word-line {
    display: block;
  }

  .picker__word-line:first-child {
    font-size: 0.82em;
    transform: translateX(-2%);
  }

  .picker__word-name {
    transform: rotate(-7deg) translateY(-8%);
  }

  .picker__char {
    display: inline-block;
    transform: rotate(var(--lean)) scaleY(var(--stretch));
    animation: picker-rise calc(var(--time-pop) * 1.4) var(--ease-spring) backwards;
    animation-delay: calc(var(--order) * var(--stagger) + 0.18s);
  }

  @keyframes picker-rise {
    from {
      opacity: 0;
      transform: translateY(0.6em) rotate(calc(var(--lean) * 6)) scale(0.6);
    }
    30% {
      opacity: 1;
    }
  }

  .picker__lid {
    --lid: var(--picker-lid);
    --lid-face: color-mix(in srgb, var(--lid) 42%, var(--paper));
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    display: grid;
    place-content: center;
    justify-items: center;
    width: 1em;
    height: 1em;
    margin: -0.5em 0 0 -0.5em;
    font-size: clamp(11rem, 22vw, 21rem);
    border-radius: var(--radius-pill);
    background: radial-gradient(circle closest-side, var(--lid-face) calc(0.5em - var(--lid-rim)), var(--lid) calc(0.5em - var(--lid-rim) + 1px));
    box-shadow:
      0 0.025em 0 color-mix(in srgb, var(--lid) 65%, var(--ink)),
      0 0.09em 0.16em var(--shade),
      0 0 0 0.06em color-mix(in srgb, var(--lid) 35%, transparent);
    color: var(--ink);
  }

  .picker__lid-print {
    position: absolute;
    inset: 0;
    font-family: var(--font-display);
    font-weight: 800;
    text-transform: uppercase;
    text-anchor: middle;
  }

  .picker__lid-arc {
    font-size: 8.4px;
    letter-spacing: 0.04em;
    fill: var(--ink);
  }

  .picker__lid-foot {
    font-size: 11.5px;
    font-weight: 900;
    letter-spacing: 0.05em;
    fill: var(--paper);
  }

  .picker__lid-brand {
    padding: 0.35em 0.8em 0.25em;
    border-radius: 55% 45% 50% 50% / 60% 60% 40% 40%;
    background: var(--forest);
    color: var(--paper);
    font: 900 0.058em / 1 var(--font-display);
    text-transform: uppercase;
    transform: rotate(-6deg);
  }

  .picker__lid-name {
    margin: 0.03em 0 0.04em;
    font: 900 0.19em / var(--tight) var(--font-display);
    text-transform: uppercase;
    text-align: center;
    letter-spacing: -0.02em;
  }

  .picker__lid-code {
    width: 0.2em;
    height: 0.075em;
    border: 0.012em solid var(--paper);
    background: repeating-linear-gradient(90deg, var(--ink) 0 1.5%, var(--paper) 1.5% 4%, var(--ink) 4% 8%, var(--paper) 8% 9.5%, var(--ink) 9.5% 10.5%, var(--paper) 10.5% 14%);
  }

  .picker__tile {
    position: absolute;
    z-index: 1;
    width: 16.5vw;
    aspect-ratio: 1;
    border-radius: var(--radius-squircle);
    box-shadow: 0.25rem 0.5rem 0 var(--shade);
    transition: transform var(--time-pop) var(--ease-spring);
  }

  .picker__tile svg {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
  }

  .picker__tile--jar {
    left: 0;
    top: 15%;
    background: var(--grape);
    transform: rotate(-8deg);
  }

  .picker__tile--slices {
    right: 0;
    top: 24%;
    background: var(--paper);
    overflow: hidden;
    transform: rotate(9deg);
  }

  .picker__tile--jar:hover,
  .picker__show--rolling .picker__tile--slices {
    transform: rotate(4deg) scale(1.05);
  }

  .picker__tile--slices:hover,
  .picker__show--rolling .picker__tile--jar {
    transform: rotate(-5deg) scale(1.05);
  }

  .picker__tape {
    position: absolute;
    left: 50%;
    top: -0.9vw;
    z-index: 1;
    width: 7vw;
    height: 2.6vw;
    margin-left: -3.5vw;
    background: var(--tape);
    opacity: 0.92;
    transform: rotate(-5deg);
    clip-path: polygon(0 8%, 3% 0, 97% 4%, 100% 14%, 98% 50%, 100% 92%, 96% 100%, 4% 96%, 0 84%, 2% 50%);
  }

  .picker__tile--slices .picker__tape {
    left: 30%;
    transform: rotate(7deg);
  }

  .picker__fan {
    fill: var(--tangerine);
  }

  .picker__jar-glass {
    fill: color-mix(in srgb, var(--paper) 78%, var(--sky));
  }

  .picker__jar-pickle {
    fill: var(--forest);
  }

  .picker__jar-cap {
    fill: var(--picker-lid);
    transition: fill var(--time-slow) var(--ease-out);
  }

  .picker__slice {
    position: absolute;
    width: 58%;
    aspect-ratio: 1;
    border-radius: var(--radius-pill);
    background:
      radial-gradient(circle closest-side, var(--paper) 9%, transparent 10%) 50% 22% / 22% 22% no-repeat,
      radial-gradient(circle closest-side, var(--paper) 9%, transparent 10%) 26% 62% / 22% 22% no-repeat,
      radial-gradient(circle closest-side, var(--paper) 9%, transparent 10%) 74% 62% / 22% 22% no-repeat,
      radial-gradient(circle closest-side, var(--lime) 80%, var(--forest) 82%);
  }

  .picker__slice:nth-of-type(2) {
    left: -8%;
    top: 34%;
  }

  .picker__slice:nth-of-type(3) {
    left: 46%;
    top: -10%;
  }

  .picker__slice:nth-of-type(4) {
    left: 42%;
    top: 50%;
  }

  .picker__taste {
    position: absolute;
    left: 63%;
    top: 12%;
    z-index: 3;
    display: grid;
    place-items: center;
    width: clamp(4.6rem, 7.6vw, 7rem);
    aspect-ratio: 1;
    border-radius: var(--radius-pill);
    background: var(--paper);
    outline: 2px dotted var(--pine);
    outline-offset: -0.5rem;
    color: var(--pine);
    font: 900 clamp(1.05rem, 1.7vw, 1.6rem) / 1 var(--font-display);
    text-transform: uppercase;
    text-decoration: none;
    box-shadow: 0 0.2rem 0 var(--shade);
    transform: rotate(12deg);
    transition: transform var(--time-pop) var(--ease-spring);
  }

  .picker__taste:hover,
  .picker__taste:focus-visible {
    transform: rotate(-8deg) scale(1.12);
  }

  /* the rack of small lids */
  .picker__rack {
    grid-area: rack;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.6rem;
  }

  .picker__hint {
    margin: 0 0.6rem 0.2rem 0;
    font: 400 var(--size-hand) / 1 var(--font-hand);
    text-transform: lowercase;
    color: var(--picker-copy);
    transform: rotate(-8deg);
    transition: color var(--time-slow) var(--ease-out);
  }

  .picker__pick {
    display: grid;
    place-items: center;
    width: 1em;
    height: 1em;
    padding: 0;
    border: 0;
    font-size: clamp(4.2rem, 6.4vw, 6rem);
    border-radius: var(--radius-pill);
    background: radial-gradient(circle closest-side, color-mix(in srgb, var(--lid) 42%, var(--paper)) calc(0.5em - var(--lid-rim)), var(--lid) calc(0.5em - var(--lid-rim) + 1px));
    box-shadow: 0 0.03em 0 color-mix(in srgb, var(--lid) 65%, var(--ink)), 0 0.08em 0.12em var(--shade);
    color: var(--ink);
    cursor: pointer;
    transition: transform var(--time-pop) var(--ease-spring);
  }

  .picker__pick b {
    font: 900 0.19em / var(--tight) var(--font-display);
    text-transform: uppercase;
  }

  .picker__pick:nth-of-type(odd) {
    transform: rotate(-8deg);
  }

  .picker__pick:nth-of-type(even) {
    transform: translateX(-35%) rotate(10deg);
  }

  .picker__pick:hover,
  .picker__pick:focus-visible {
    transform: translateX(-18%) rotate(-14deg) scale(1.12);
  }

  .picker__pick[aria-pressed="true"] {
    transform: translateX(-55%) rotate(0deg) scale(1.18);
    outline: 2px dotted var(--picker-copy);
    outline-offset: 0.25rem;
  }

  @media (max-width: 59.99rem) {
    .picker__stage {
      grid-template-columns: minmax(0, 1fr);
      grid-template-areas: "chip" "show" "rack" "about";
      gap: 1.5rem;
      padding-top: 2rem;
    }

    .picker__show {
      height: 108vw;
    }

    .picker__word {
      justify-content: flex-start;
      gap: 33vw;
      padding-top: 1vw;
      font-size: 27vw;
    }

    .picker__lid {
      top: 36vw;
      margin-top: -0.5em;
      font-size: clamp(10rem, 44vw, 21rem);
    }

    .picker__tile {
      top: auto;
      bottom: 0;
      width: 39vw;
    }

    .picker__tile--jar {
      left: 6%;
    }

    .picker__tile--slices {
      right: 6%;
    }

    .picker__tape {
      top: -2.5vw;
      width: 16vw;
      height: 6vw;
      margin-left: -8vw;
    }

    .picker__taste {
      left: 68%;
      top: 15vw;
    }

    .picker__rack {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: center;
      justify-content: center;
      gap: 0.9rem;
    }

    .picker__hint {
      flex-basis: 100%;
      margin: 0;
      text-align: center;
    }

    .picker__pick,
    .picker__pick:nth-of-type(even),
    .picker__pick:hover,
    .picker__pick:focus-visible {
      transform: rotate(-6deg);
    }

    .picker__pick[aria-pressed="true"] {
      transform: rotate(0deg) scale(1.14);
    }

    .picker__about {
      padding-bottom: 0;
      text-align: center;
    }

    .picker__tags {
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: center;
      margin-bottom: 1.25rem;
    }

    .picker__text {
      max-width: 26rem;
      margin: 0 auto;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .picker__char,
    .picker__swap {
      animation: none;
    }

    .picker__stage,
    .picker__tile,
    .picker__pick,
    .picker__taste {
      transition: none;
    }
  }
</style>

<script>
  (() => {
    const LEANS = [-3, 2.2, -1.4, 3.1, -2.4, 1.2, -3.4, 2.6];
    const STRETCHES = [1, 1.05, 0.97, 1.04, 0.98, 1.06, 1, 0.96];
    const ROLL_OUT = [{ transform: 'none' }, { transform: 'translateX(-65vw) rotate(-300deg)' }];
    const ROLL_IN = [{ transform: 'translateX(65vw) rotate(300deg)' }, { transform: 'none' }];
    const calm = matchMedia('(prefers-reduced-motion: reduce)');
    const token = (name) => `var(--${name})`;

    const cutIntoLetters = (line, word) => {
      line.textContent = '';
      line.setAttribute('aria-label', word);
      [...word].forEach((letter, order) => {
        const char = document.createElement('span');
        char.className = 'picker__char';
        char.setAttribute('aria-hidden', 'true');
        char.textContent = letter;
        char.style.setProperty('--order', order);
        char.style.setProperty('--lean', `${LEANS[order % LEANS.length]}deg`);
        char.style.setProperty('--stretch', STRETCHES[order % STRETCHES.length]);
        line.append(char);
      });
    };

    const replay = (element) => {
      element.classList.remove('picker__swap');
      void element.offsetWidth;
      element.classList.add('picker__swap');
    };

    const setUp = (picker) => {
      const show = picker.querySelector('.picker__show');
      const lid = picker.querySelector('.picker__lid');
      const picks = [...picker.querySelectorAll('.picker__pick')];
      const wordLines = [...picker.querySelectorAll('.picker__word-line')];
      const about = picker.querySelector('.picker__about');
      const spring = getComputedStyle(picker).getPropertyValue('--ease-spring').trim();

      const print = (flavour) => {
        picker.style.setProperty('--picker-stage', token(flavour.stage));
        picker.style.setProperty('--picker-ink', token(flavour.ink));
        picker.style.setProperty('--picker-copy', token(flavour.copy));
        picker.style.setProperty('--picker-lid', token(flavour.lid));
        picker.querySelector('.picker__lid-name').innerHTML = flavour.name.split('|').map((part) => part.replace('&', '&amp;')).join('<br>');
        picker.querySelector('.picker__lid-note').textContent = flavour.note;
        picker.querySelector('.picker__tags').replaceChildren(
          ...flavour.tags.split('|').map((tag) => Object.assign(document.createElement('li'), { className: 'picker__tag', textContent: tag }))
        );
        picker.querySelector('.picker__text').textContent = flavour.text;
        wordLines.forEach((line, index) => cutIntoLetters(line, index ? flavour.word : 'The'));
        replay(about);
      };

      const choose = async (pick) => {
        if (pick.getAttribute('aria-pressed') === 'true' || show.classList.contains('picker__show--rolling')) return;
        picks.forEach((other) => other.setAttribute('aria-pressed', other === pick));
        if (calm.matches) return print(pick.dataset);
        show.classList.add('picker__show--rolling');
        await lid.animate(ROLL_OUT, { duration: 320, easing: 'ease-in' }).finished;
        print(pick.dataset);
        await lid.animate(ROLL_IN, { duration: 650, easing: spring }).finished;
        show.classList.remove('picker__show--rolling');
      };

      wordLines.forEach((line) => cutIntoLetters(line, line.textContent.trim()));
      picks.forEach((pick) => pick.addEventListener('click', () => choose(pick)));
    };

    document.querySelectorAll('.picker').forEach(setUp);
  })();
</script>

Similar components

Shop shelf

Shop shelf

Product page

Product page

Dial showcase

Dial showcase

Product grid

Product grid

Film player

Film player

Showcase with progress tabs

Showcase with progress tabs

Theme flood

Theme flood

Question wheel

Question wheel