kitbash Sign in Connect agent
Components

Swapping chip wordmark

Centred row of big word chips, the mark, a fixed word and a changing word, that swap words, grow to fit and change highlighter every few seconds.

Part of the style

Highlighter Word Chips

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #030101;
  --paper: #dfe4e8;
  --chip: rgba(207, 212, 216, 0.7);
  --chip-solid: #cfd4d8;
  --chip-press: #c4c9cd;
  --ink-mute: rgba(3, 1, 1, 0.45);
  --veil: rgba(223, 228, 232, 0.72);
  --periwinkle: #df531e;
  --mint: #df531e;
  --lemon: #ec683c;
  --blush: #df531e;
}
</style>

<section class="hero" aria-label="Dawdle Studio">
  <h1 class="hero__mark">
    <span class="hero__chip hero__chip--icon" data-slot="0" aria-hidden="true">
      <svg class="hero__snail" viewBox="0 0 32 32">
        <path d="M3 26.5c0-1.6 1.2-2.5 3-2.5h15.5c2.2 0 3.4-1.2 4-3.6l1-5.4h2.6l-1.1 6.6c-.7 4.4-2.9 6.9-6.9 6.9H5c-1.3 0-2-.8-2-2Z" fill="currentColor"/>
        <g class="hero__shell">
          <circle cx="14" cy="16" r="8.4" fill="currentColor"/>
          <path d="M14.4 16.4a1.6 1.6 0 1 1-1.4-2.1 3.4 3.4 0 1 1-2.6 4.6 5.4 5.4 0 1 1 9.2-3.8" fill="none" stroke="var(--paper)" stroke-width="1.5" stroke-linecap="round"/>
        </g>
        <g class="hero__eyes">
          <path d="M27 15l-2.2-7.6M28.6 15l1.2-7.2" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/>
          <circle cx="24.6" cy="6.9" r="1.4" fill="currentColor"/>
          <circle cx="29.9" cy="6.6" r="1.4" fill="currentColor"/>
        </g>
      </svg>
    </span>
    <span class="hero__chip" data-slot="1"><span class="hero__window"><span class="hero__word">Dawdle</span></span></span>
    <span class="hero__chip" data-slot="2"><span class="hero__window"><span class="hero__word">Studio</span></span></span>
  </h1>

  <ul class="hero__phrases" aria-label="What we are">
    <li data-tones="chip chip periwinkle"><span>Dawdle</span> <span>Studio</span></li>
    <li data-tones="lemon chip mint"><span>Slow</span> <span>Making</span></li>
    <li data-tones="mint lemon periwinkle"><span>Careful</span> <span>Objects</span></li>
    <li data-tones="chip periwinkle chip"><span>Patient</span> <span>Books</span></li>
    <li data-tones="periwinkle chip blush"><span>Unhurried</span> <span>Rooms</span></li>
  </ul>

  <p class="hero__line">
    <span class="hero__tag">A small design studio</span>
    <span class="hero__tag">Objects, books and rooms</span>
    <span class="hero__tag hero__tag--lit">Since 2019</span>
  </p>
</section>

<style>
  .hero {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-l);
    min-height: clamp(26rem, 56vw, 44rem);
    padding: var(--section-space) var(--edge);
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    text-align: center;
  }
  .hero__mark {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--chip-gap);
    margin: 0;
    font-size: var(--display);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking);
    line-height: var(--leading-chip);
  }
  .hero__chip {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--chip-pad-x);
    border-radius: var(--radius);
    background: var(--tone, var(--chip));
    transition: background-color var(--fast) var(--ease);
  }
  .hero__chip--icon {
    width: 1.25em;
    justify-content: center;
    padding: 0;
  }
  .hero__snail {
    width: 0.86em;
    height: 0.86em;
    overflow: visible;
  }
  .hero__eyes {
    transform-origin: 27px 15px;
    animation: hero-peek 2.6s var(--ease-swap) infinite;
  }
  @keyframes hero-peek {
    0%, 70%, 100% { transform: none; }
    80% { transform: rotate(-12deg) scaleY(0.82); }
  }
  .hero__window {
    display: inline-grid;
    height: calc(var(--leading-chip) * 1em);
    overflow: hidden;
    transition: width var(--grow) var(--ease-grow);
  }
  .hero__word {
    grid-area: 1 / 1;
    justify-self: start;
    white-space: nowrap;
    transition: transform var(--swap) var(--ease-swap);
  }
  .hero__word.is-below { transform: translateY(105%); }
  .hero__word.is-above { transform: translateY(-105%); }

  /* The phrases are read by people without the animation and by generations; the chips show them one at a time. */
  .hero__phrases {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    margin: 0;
    padding: 0;
  }

  .hero__line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--chip-gap);
    margin: 0;
    font-size: var(--text-s);
  }
  .hero__tag {
    padding: var(--space-xs) var(--space-s);
    border-radius: var(--radius);
    background: var(--chip);
  }
  .hero__tag--lit {
    background: var(--mint);
  }

  .hero.is-paused .hero__eyes { animation-play-state: paused; }
  @media (prefers-reduced-motion: reduce) {
    .hero__eyes { animation: none; }
  }
</style>

<script>
  (() => {
    const still = window.matchMedia('(prefers-reduced-motion: reduce)');
    for (const root of document.querySelectorAll('.hero')) {
      const chips = [...root.querySelectorAll('.hero__chip')];
      const phrases = [...root.querySelectorAll('.hero__phrases li')].map((item) => ({
        words: [...item.querySelectorAll('span')].map((span) => span.textContent),
        tones: (item.dataset.tones || '').split(' '),
      }));
      if (phrases.length < 2) continue;
      let index = 0;
      let timer = 0;
      let visible = true;

      const paint = (tones) => chips.forEach((chip, i) => chip.style.setProperty('--tone', `var(--${tones[i] || 'chip'})`));

      const fit = (win, word) => { win.style.width = `${word.getBoundingClientRect().width}px`; };
      for (const win of root.querySelectorAll('.hero__window')) fit(win, win.querySelector('.hero__word'));
      document.fonts && document.fonts.ready.then(() => {
        for (const win of root.querySelectorAll('.hero__window')) fit(win, win.lastElementChild);
      });

      const swapWord = (win, text, delay) => {
        const old = win.lastElementChild;
        if (old.textContent === text) return;
        const next = document.createElement('span');
        next.className = 'hero__word is-below';
        next.textContent = text;
        win.appendChild(next);
        setTimeout(() => {
          fit(win, next);
          old.classList.add('is-above');
          next.classList.remove('is-below');
          setTimeout(() => old.remove(), 850);
        }, delay);
      };

      const step = () => {
        index = (index + 1) % phrases.length;
        const phrase = phrases[index];
        paint(phrase.tones);
        root.querySelectorAll('.hero__window').forEach((win, i) => swapWord(win, phrase.words[i], 30 + i * 120));
      };
      const run = () => {
        clearInterval(timer);
        if (visible && !still.matches && !document.hidden) timer = setInterval(step, 2600);
      };

      paint(phrases[0].tones);
      new IntersectionObserver(([entry]) => { visible = entry.isIntersecting; root.classList.toggle('is-paused', !visible); run(); }).observe(root);
      document.addEventListener('visibilitychange', run);
      still.addEventListener('change', run);
    }
  })();
</script>

Similar components

Sketch statement

Sketch statement

Turning orb

Turning orb

Statement and rising panel

Statement and rising panel

Iris lens opener

Iris lens opener

Cast-in hero

Cast-in hero

Sunburst stage

Sunburst stage

Huge line over a photograph

Huge line over a photograph

Capitals over a portrait

Capitals over a portrait