kitbash Sign in Connect agent
Components

Theme flood

Grey swatch squares with rings that thicken on hover; clicking one floods the section in its colour with a goo blob from the click point while the mark pops up in the middle. A stepped statement and a note sit between them.

Part of the style

Ink Bloom Column

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #a29292;
  --ink: #08150a;
  --mist: #9c8c8c;
  --tint: rgba(8, 21, 10, 0.05);
  --hairline: rgba(8, 21, 10, 0.1);
  --ink-ghost: rgba(8, 21, 10, 0.1);
  --ink-soft: rgba(8, 21, 10, 0.5);
  --menu-1: #8c7b7b;
  --menu-2: #918181;
  --menu-3: #978787;
  --theme-slate: #877676;
  --on-ink: #a29292;
  --theme-ember: #7a805f;
  --theme-oxblood: #7a7f5e;
  --theme-lichen: #628966;
}
</style>

<section class="themes" aria-label="Choose a room colour">
  <svg class="themes__flood" aria-hidden="true" focusable="false">
    <defs>
      <filter class="themes__goo" x="-20%" y="-20%" width="140%" height="140%" color-interpolation-filters="sRGB">
        <feGaussianBlur in="SourceGraphic" stdDeviation="22" />
        <feColorMatrix type="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 20 -8" />
      </filter>
    </defs>
    <g class="themes__blobs"></g>
  </svg>
  <span class="themes__rule" aria-hidden="true"></span>
  <div class="themes__swatches" role="group" aria-label="Room colour">
    <button class="themes__swatch is-current" type="button" aria-pressed="true" aria-label="Paper white" style="--swatch: var(--paper)"><span class="themes__ring"></span></button>
    <button class="themes__swatch" type="button" aria-pressed="false" aria-label="Slate grey" style="--swatch: var(--theme-slate)"><span class="themes__ring"></span></button>
    <button class="themes__swatch" type="button" aria-pressed="false" aria-label="Ember orange" style="--swatch: var(--theme-ember)"><span class="themes__ring"></span></button>
    <button class="themes__swatch" type="button" aria-pressed="false" aria-label="Lichen green" style="--swatch: var(--theme-lichen)"><span class="themes__ring"></span></button>
    <button class="themes__swatch" type="button" aria-pressed="false" aria-label="Oxblood red" style="--swatch: var(--theme-oxblood)"><span class="themes__ring"></span></button>
  </div>
  <p class="themes__note" data-goo>Every room rings differently. Pick a wall colour and the page takes it on, the way a hall takes on a voice.</p>
  <h2 class="themes__statement">
    <span class="themes__first" data-goo><span class="themes__word">the</span><span class="themes__word">quiet</span></span>
    <span class="themes__line" data-goo>parts deserve</span>
    <span class="themes__line" data-goo>attention.</span>
  </h2>
  <p class="themes__foot" data-goo>&copy; &rsquo;26</p>
  <svg class="themes__totem" viewBox="0 0 100 164" aria-hidden="true" focusable="false">
    <path class="themes__pebble" d="M98.0 82.0C99.1 94.8 95.8 111.5 91.8 122.2C87.8 132.9 80.5 140.1 74.0 146.0C67.5 152.0 60.0 158.1 53.0 157.9C46.0 157.6 38.2 150.9 31.7 144.4C25.3 137.9 18.5 129.5 14.3 119.1C10.1 108.7 7.7 95.0 6.6 82.0C5.4 69.0 4.5 52.8 7.3 40.9C10.1 29.0 16.9 15.2 23.5 10.4C30.1 5.6 39.7 9.9 47.0 11.9C54.3 13.8 61.1 16.4 67.5 21.9C73.8 27.5 80.2 35.3 85.2 45.4C90.3 55.4 96.9 69.2 98.0 82.0Z" />
    <g class="themes__face"><circle cx="40" cy="66" r="6" /><path d="M54 56a14 14 0 0 1 0 20" /><path d="M63 49a24 24 0 0 1 0 34" /></g>
  </svg>
</section>

<style>
  .themes {
    position: relative;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    column-gap: var(--gap);
    padding: var(--edge) var(--edge) var(--space-l);
    overflow: clip;
    background: var(--room, var(--paper));
    isolation: isolate;
  }
  .themes > :not(.themes__flood, .themes__totem) { position: relative; z-index: 1; }
  .themes p, .themes h2 { margin: 0; font-weight: inherit; }

  .themes__flood {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
  }

  .themes__rule {
    position: absolute !important;
    top: 0;
    bottom: 0;
    left: calc(var(--edge) + 3 * (100% - 2 * var(--edge) - 7 * var(--gap)) / 8 + 2.5 * var(--gap));
    width: var(--stroke);
    background: var(--ink);
  }

  /* Squares sit on columns 1, 4, 5, 7 and 8, as loose as the grid allows. */
  .themes__swatches {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    margin-top: var(--space-l);
  }
  .themes__swatch:nth-child(1) { grid-column: 1; }
  .themes__swatch:nth-child(2) { grid-column: 4; }
  .themes__swatch:nth-child(3) { grid-column: 5; }
  .themes__swatch:nth-child(4) { grid-column: 7; }
  .themes__swatch:nth-child(5) { grid-column: 8; }
  .themes__swatch {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    min-width: var(--tap);
    padding: 0;
    border: 0;
    background: var(--tint);
    cursor: pointer;
  }
  .themes__swatch:focus-visible { outline: var(--stroke) solid var(--ink); outline-offset: 3px; }
  .themes__ring {
    width: max(24px, 2.2222vw);
    height: max(24px, 2.2222vw);
    border: var(--ring-thin) solid var(--swatch);
    border-radius: var(--radius-round);
    transition: border-width var(--dur-s) var(--ease-out);
  }
  .themes__swatch:hover .themes__ring,
  .themes__swatch:focus-visible .themes__ring,
  .themes__swatch.is-current .themes__ring {
    border-width: var(--ring-thick);
  }

  .themes__note {
    grid-column: 4 / span 2;
    max-width: 34ch;
    margin-top: var(--space-m) !important;
  }
  .themes__statement {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    margin-top: var(--space-l) !important;
    font-size: var(--text-xl);
    line-height: var(--leading-xl);
    letter-spacing: var(--tracking-xl);
  }
  .themes__first {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
  }
  .themes__word:first-child { grid-column: 2 / span 2; justify-self: end; }
  .themes__word:last-child { grid-column: 4 / -1; }
  .themes__line { grid-column: 3 / -1; display: block; }
  .themes__foot {
    grid-column: 4 / span 2;
    margin-top: var(--space-l) !important;
  }

  /* The mark that pops up in the middle while a new colour floods in. */
  .themes__totem {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    width: max(140px, 16vw);
    height: auto;
    translate: -50% -50%;
    scale: 0;
    pointer-events: none;
  }
  .themes__pebble { fill: var(--ink); }
  .themes__face { fill: var(--room, var(--paper)); stroke: var(--room, var(--paper)); stroke-width: 4; stroke-linecap: round; }
  .themes__face path { fill: none; }
  .themes.is-showing .themes__totem { scale: 1; transition: scale var(--dur-m) var(--ease-out); }
  .themes.is-leaving .themes__totem { scale: 0; transition: scale var(--dur-s) var(--ease-in); }

  @media (max-width: 47.99rem) {
    .themes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .themes__rule { left: calc(var(--edge) + (100% - 2 * var(--edge) - 3 * var(--gap)) / 4 + 0.5 * var(--gap)); }
    .themes__swatches { display: flex; gap: var(--space-s); }
    .themes__swatch { flex: 1 1 0; }
    .themes__note { grid-column: 2 / -1; }
    .themes__word:first-child { grid-column: 1; }
    .themes__word:last-child { grid-column: 2 / -1; }
    .themes__line { grid-column: 1 / -1; }
    .themes__foot { grid-column: 2 / -1; }
  }
</style>

<script>
(() => {
  /* Goo reveal: each line starts as a heavy blur through a hard alpha threshold and grows out of ink blobs.
     Blocks marked data-goo reveal when they come into view; their data-line children follow each other. */
  function revealOnView(root) {
    if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
    const styles = getComputedStyle(root);
    const time = (name) => parseFloat(styles.getPropertyValue(name)) * 1000;
    const durL = time('--dur-l'), stagger = time('--stagger');
    const most = parseFloat(styles.getPropertyValue('--goo-blur'));
    const [x1, y1, x2, y2] = styles.getPropertyValue('--ease-out').match(/-?[\d.]+/g).map(Number);
    const curve = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t * t * (1 - t) + t ** 3;
    const easeOut = (x) => {
      let low = 0, high = 1, t = x;
      for (let step = 0; step < 24; step += 1) { t = (low + high) / 2; if (curve(x1, x2, t) < x) low = t; else high = t; }
      return curve(y1, y2, t);
    };
    const defs = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
    defs.setAttribute('aria-hidden', 'true');
    defs.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden';
    root.prepend(defs);
    const prepare = (line) => {
      const ns = 'http://www.w3.org/2000/svg';
      const filter = document.createElementNS(ns, 'filter');
      const blur = document.createElementNS(ns, 'feGaussianBlur');
      const matrix = document.createElementNS(ns, 'feColorMatrix');
      filter.id = `themes-goo-${Math.random().toString(36).slice(2, 9)}`;
      Object.entries({ x: '-25%', y: '-25%', width: '150%', height: '150%', 'color-interpolation-filters': 'sRGB' }).forEach(([key, value]) => filter.setAttribute(key, value));
      blur.setAttribute('in', 'SourceGraphic');
      matrix.setAttribute('type', 'matrix');
      filter.append(blur, matrix);
      defs.append(filter);
      const scale = Math.max(0.3, parseFloat(getComputedStyle(line).fontSize) / 90);
      line._goo = (deviation, amp, offset) => {
        blur.setAttribute('stdDeviation', (deviation * scale).toFixed(2));
        matrix.setAttribute('values', `1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 ${amp} ${offset}`);
      };
      line._goo(most, 20, -8);
      line.style.filter = `url(#${filter.id})`;
    };
    const play = (line, delay) => {
      const begin = performance.now() + delay;
      const frame = (now) => {
        const elapsed = now - begin;
        if (elapsed < 0) { requestAnimationFrame(frame); return; }
        const blurDone = Math.min(1, elapsed / durL);
        const threshold = Math.min(1, Math.max(0, (elapsed - durL * 0.65) / (durL * 0.35)));
        line._goo(most * (1 - easeOut(blurDone)), 20 - 19 * threshold, -8 + 8 * threshold);
        if (blurDone < 1) requestAnimationFrame(frame); else line.style.filter = '';
      };
      requestAnimationFrame(frame);
    };
    const linesOf = (block) => {
      const lines = [...block.querySelectorAll('[data-line]')];
      return lines.length ? lines : [block];
    };
    const blocks = [...root.querySelectorAll('[data-goo]')];
    blocks.forEach((block) => linesOf(block).forEach(prepare));
    const seen = new IntersectionObserver((entries) => {
      entries.filter((entry) => entry.isIntersecting).forEach((entry, order) => {
        seen.unobserve(entry.target);
        linesOf(entry.target).forEach((line, index) => play(line, (order + index) * stagger));
      });
    }, { threshold: 0.1 });
    blocks.forEach((block) => seen.observe(block));
  }
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const SATELLITES = 11;
  const TOTEM_HOLD_MS = 1600;
  let rooms = 0;

  function token(root, name) { return getComputedStyle(root).getPropertyValue(name).trim(); }
  function ms(root, name) { return parseFloat(token(root, name)) * 1000; }

  function bezier(spec) {
    const [x1, y1, x2, y2] = spec.match(/-?[\d.]+/g).map(Number);
    const curve = (a, b, t) => 3 * a * t * (1 - t) ** 2 + 3 * b * t * t * (1 - t) + t ** 3;
    return (x) => {
      let low = 0, high = 1, t = x;
      for (let step = 0; step < 24; step += 1) {
        t = (low + high) / 2;
        if (curve(x1, x2, t) < x) low = t; else high = t;
      }
      return curve(y1, y2, t);
    };
  }

  function tween(duration, ease, update) {
    return new Promise((done) => {
      const start = performance.now();
      const frame = (now) => {
        const progress = Math.min(1, (now - start) / duration);
        update(ease(progress));
        if (progress < 1) requestAnimationFrame(frame); else done();
      };
      requestAnimationFrame(frame);
    });
  }

  /* A flood is one big circle from the click point plus satellites that run ahead or lag, merged by the goo filter. */
  function flood(root, x, y, color) {
    const svg = 'http://www.w3.org/2000/svg';
    const group = root.querySelector('.themes__blobs');
    const box = root.getBoundingClientRect();
    const reach = Math.hypot(Math.max(x, box.width - x), Math.max(y, box.height - y)) * 1.15;
    const blobs = [{ dx: 0, dy: 0, size: 1, lead: 0 }];
    for (let index = 0; index < SATELLITES; index += 1) {
      const angle = (index / SATELLITES) * Math.PI * 2 + Math.random() * 0.5;
      const distance = 0.25 + Math.random() * 0.35;
      blobs.push({ dx: Math.cos(angle) * distance, dy: Math.sin(angle) * distance, size: 0.35 + Math.random() * 0.3, lead: Math.random() * 0.25 });
    }
    const circles = blobs.map(() => {
      const circle = document.createElementNS(svg, 'circle');
      circle.setAttribute('fill', color);
      group.append(circle);
      return circle;
    });
    const ease = bezier(token(root, '--ease-out'));
    return tween(ms(root, '--dur-m'), (x01) => x01, (time) => {
      blobs.forEach((blob, index) => {
        const local = ease(Math.min(1, time * (1 + blob.lead)));
        const radius = reach * blob.size * local;
        circles[index].setAttribute('cx', x + blob.dx * reach * local);
        circles[index].setAttribute('cy', y + blob.dy * reach * local);
        circles[index].setAttribute('r', Math.max(0, radius));
      });
    }).then(() => {
      root.style.setProperty('--room', color);
      circles.forEach((circle) => circle.remove());
    });
  }

  function showTotem(root) {
    clearTimeout(root._totem);
    root.classList.remove('is-leaving');
    root.classList.add('is-showing');
    root._totem = setTimeout(() => {
      root.classList.replace('is-showing', 'is-leaving');
    }, TOTEM_HOLD_MS);
  }

  function setUp(root) {
    rooms += 1;
    const filter = root.querySelector('.themes__goo');
    filter.id = `themes-goo-${rooms}`;
    root.querySelector('.themes__blobs').setAttribute('filter', `url(#${filter.id})`);
    const swatches = [...root.querySelectorAll('.themes__swatch')];
    let busy = Promise.resolve();

    swatches.forEach((swatch) => swatch.addEventListener('click', (event) => {
      if (swatch.classList.contains('is-current')) return;
      swatches.forEach((other) => {
        other.classList.toggle('is-current', other === swatch);
        other.setAttribute('aria-pressed', String(other === swatch));
      });
      const color = getComputedStyle(swatch).getPropertyValue('--swatch').trim();
      if (still.matches) { root.style.setProperty('--room', color); return; }
      const box = root.getBoundingClientRect();
      const fromPointer = event.clientX || event.clientY;
      const target = swatch.getBoundingClientRect();
      const x = (fromPointer ? event.clientX : target.left + target.width / 2) - box.left;
      const y = (fromPointer ? event.clientY : target.top + target.height / 2) - box.top;
      showTotem(root);
      busy = busy.then(() => flood(root, x, y, color));
    }));
  }

  document.querySelectorAll('.themes').forEach((root) => { setUp(root); revealOnView(root); });
})();
</script>

Similar components

Showcase with progress tabs

Showcase with progress tabs

Instrument panel

Instrument panel

Two-part bar

Two-part bar

Keypad and knob

Keypad and knob

Film player

Film player

Word-by-word testimonial

Word-by-word testimonial

Services table

Services table

Ledger

Ledger