kitbash Sign in Connect agent
Components

Ink switcher

A feature panel with a strip of seven ink swatches along its foot; picking one recolours the whole panel, pictures included.

Part of the style

One Ink Event Board

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #131313;
  --ink: #ffffff;
  --ink-light: #000000;
  --ink-brown: #ffffff;
  --ink-green: #997d73;
  --ink-blue: #b2958b;
  --ink-red: #b2958b;
  --ink-orange: #988077;
  --ink-pink: #a5897f;
  --ink-violet: #82706b;
}
</style>

<section class="inks" aria-label="House ink">
  <div class="inks__body">
    <figure class="inks__pic">
      <img class="inks__img" src="assets/wet-night.jpg" alt="A park path on a wet night, trees and lamps blurred by rain" width="949" height="1200" loading="lazy">
    </figure>
    <div class="inks__text">
      <p class="inks__word">Ink</p>
      <p class="inks__meta"><span>House colour</span><span>Ink <span class="inks__number">04</span> / <span class="inks__name">umber</span></span></p>
      <h2 class="inks__title">Every visit, the house is printed in one ink. Pick another and the whole page follows: words, rules and pictures.</h2>
      <p class="inks__copy">Seven inks hang by the door of the print room. Whichever was mixed last is the colour of the week.</p>
    </div>
  </div>
  <div class="inks__strip" role="radiogroup" aria-label="Choose an ink">
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Green" data-name="green" style="--swatch: var(--ink-green)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Blue" data-name="blue" style="--swatch: var(--ink-blue)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Red" data-name="red" style="--swatch: var(--ink-red)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="true" aria-label="Umber" data-name="umber" style="--swatch: var(--ink-brown)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Pink" data-name="pink" style="--swatch: var(--ink-pink)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Orange" data-name="orange" style="--swatch: var(--ink-orange)"></button>
    <button class="inks__swatch" type="button" role="radio" aria-checked="false" aria-label="Violet" data-name="violet" style="--swatch: var(--ink-violet)"></button>
  </div>
</section>

<style>
  .inks {
    border: var(--rule) solid var(--ink);
    background: var(--paper);
    color: var(--ink);
  }
  .inks,
  .inks__body,
  .inks__text,
  .inks__pic,
  .inks__pic::after,
  .inks__strip {
    transition: color var(--slide) var(--ease), border-color var(--slide) var(--ease), background-color var(--slide) var(--ease);
  }
  .inks__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  }
  .inks__pic {
    position: relative;
    isolation: isolate;
    margin: 0;
    overflow: hidden;
    min-height: clamp(18rem, 36vw, 30rem);
    border-right: var(--rule) solid var(--ink);
  }
  .inks__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.2) brightness(1.15);
    transform: scale(1.14);
  }
  .inks__pic::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--ink);
    mix-blend-mode: screen;
  }
  .inks__text {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
    padding: 0 var(--pad) var(--pad-end);
  }
  .inks__word {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--display-huge);
    font-weight: 700;
    font-variation-settings: "wdth" var(--display-width);
    line-height: 0.95;
    letter-spacing: var(--track-display);
    text-transform: uppercase;
  }
  .inks__meta {
    display: grid;
    margin: 0;
    font: 400 var(--text-meta)/1.2 var(--font-mono);
    text-transform: uppercase;
  }
  .inks__title {
    margin: 0;
    font: 300 var(--text-title)/1.2 var(--font-title);
    max-width: 30em;
  }
  .inks__copy {
    margin: 0;
    font: 400 var(--text-mono)/1.2 var(--font-mono);
    max-width: 36em;
  }

  .inks__strip {
    display: flex;
    border-top: var(--rule) solid var(--ink);
  }
  .inks__swatch {
    flex: 1 1 0;
    min-width: 0;
    height: var(--tap);
    padding: 0;
    border: 0;
    background: linear-gradient(to top, var(--swatch) 0 var(--fill, 14px), transparent var(--fill, 14px));
    cursor: pointer;
    transition: --fill var(--slide) var(--ease);
  }
  .inks__swatch:hover,
  .inks__swatch:focus-visible {
    --fill: 26px;
    outline: none;
  }
  .inks__swatch[aria-checked="true"] {
    --fill: 44px;
  }
  @property --fill {
    syntax: "<length>";
    inherits: false;
    initial-value: 14px;
  }

  @media (max-width: 44rem) {
    .inks__body {
      grid-template-columns: 1fr;
    }
    .inks__pic {
      min-height: 0;
      aspect-ratio: 4 / 3;
      border-right: 0;
      border-bottom: var(--rule) solid var(--ink);
    }
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.inks')) {
      const swatches = [...root.querySelectorAll('.inks__swatch')];
      const number = root.querySelector('.inks__number');
      const name = root.querySelector('.inks__name');
      const pick = (swatch) => {
        root.style.setProperty('--ink', getComputedStyle(swatch).getPropertyValue('--swatch'));
        swatches.forEach((other) => other.setAttribute('aria-checked', String(other === swatch)));
        number.textContent = String(swatches.indexOf(swatch) + 1).padStart(2, '0');
        name.textContent = swatch.dataset.name;
      };
      swatches.forEach((swatch, index) => {
        swatch.addEventListener('click', () => pick(swatch));
        swatch.addEventListener('keydown', (event) => {
          const step = event.key === 'ArrowRight' ? 1 : event.key === 'ArrowLeft' ? -1 : 0;
          if (!step) return;
          const next = swatches[(index + step + swatches.length) % swatches.length];
          pick(next);
          next.focus();
        });
      });
    }
  })();
</script>

Similar components

Segmented showcase

Segmented showcase

Exposure dial

Exposure dial

Showcase with progress tabs

Showcase with progress tabs

Sky panel with tabs

Sky panel with tabs

App screen showcase

App screen showcase

Daylight readout

Daylight readout

Screen modes

Screen modes

Instrument panel

Instrument panel