kitbash Sign in Connect agent
Components

Word stack

Full-width words stacked as an accordion menu; a click squashes the word and opens its panel.

Part of the style

Stretched Word Stack

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #060001;
  --paper: #b2967d;
  --on-picture: #b2967d;
  --picture-ground: #060001;
}
</style>

<nav class="stack" aria-label="Sections">
  <div class="stack__item">
    <button class="stack__toggle" type="button" aria-expanded="false">
      <svg class="stack__word" viewBox="0 -71 100 72.5" preserveAspectRatio="none" role="img" aria-label="PLACES">
        <text x="0" y="0" textLength="100" lengthAdjust="spacingAndGlyphs">PLACES</text>
      </svg>
    </button>
    <div class="stack__panel">
      <div class="stack__inner">
        <div class="stack__body">
          <img class="stack__picture" src="assets/gulf-coast.jpg" alt="Amber cliffs rising out of a calm bay at sunset" width="800" height="562">
          <p class="stack__text"><b class="stack__label">Coast:</b> <a class="stack__link" href="#">Gull Point</a>, <a class="stack__link" href="#">Red Bay quarry</a>, <a class="stack__link" href="#">Lantern Steps</a> <b class="stack__label">Inland:</b> <a class="stack__link" href="#">Salt Road 9</a>, <a class="stack__link" href="#">Hollow Lake</a>, <a class="stack__link" href="#">The Lido, empty</a></p>
        </div>
      </div>
    </div>
  </div>
  <div class="stack__item">
    <button class="stack__toggle" type="button" aria-expanded="false">
      <svg class="stack__word" viewBox="0 -71 100 72.5" preserveAspectRatio="none" role="img" aria-label="INFO">
        <text x="0" y="0" textLength="100" lengthAdjust="spacingAndGlyphs">INFO</text>
      </svg>
    </button>
    <div class="stack__panel">
      <div class="stack__inner">
        <div class="stack__body">
          <img class="stack__picture" src="assets/cloud-study.jpg" alt="A grey sky of piled clouds over a dark ridge" width="649" height="800">
          <p class="stack__text">We are two scouts who drive out before the crew does. We find the road, the light at five, the farmer with the key, and we bring back a folder you can shoot from.</p>
        </div>
      </div>
    </div>
  </div>
  <div class="stack__item">
    <button class="stack__toggle" type="button" aria-expanded="false">
      <svg class="stack__word" viewBox="0 -71 100 72.5" preserveAspectRatio="none" role="img" aria-label="CONTACT">
        <text x="0" y="0" textLength="100" lengthAdjust="spacingAndGlyphs">CONTACT</text>
      </svg>
    </button>
    <div class="stack__panel">
      <div class="stack__inner">
        <p class="stack__text"><b class="stack__label">Mail:</b> <a class="stack__link" href="#">desk@ostrand.example</a> <b class="stack__label">Phone:</b> <a class="stack__link" href="#">+00 30 555 0142</a> <b class="stack__label">Office:</b> Kanalweg 12, Harbour District</p>
      </div>
    </div>
  </div>
</nav>

<style>
  .stack {
    --stack-tall: clamp(140px, 23vw, 320px);
    --stack-low: clamp(64px, 8vw, 116px);
    display: block;
    background: var(--paper);
  }
  .stack__toggle {
    display: block;
    width: 100%;
    height: var(--stack-tall);
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    cursor: pointer;
    transition: height var(--slow) var(--ease);
  }
  .stack__toggle:hover {
    height: calc(var(--stack-tall) * 1.08);
  }
  .stack__toggle:focus-visible {
    outline: var(--line) solid var(--ink);
    outline-offset: calc(var(--line) * -1);
  }
  .stack__item.is-open .stack__toggle {
    height: var(--stack-low);
  }
  .stack__word {
    width: 100%;
    height: 100%;
    overflow: visible;
  }
  .stack__word text {
    font-family: var(--font-display);
    font-size: 100px;
    font-weight: var(--weight-display);
    font-stretch: var(--width-word);
    fill: currentColor;
  }
  .stack__panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--slow) var(--ease);
  }
  .stack__item.is-open .stack__panel {
    grid-template-rows: 1fr;
  }
  .stack__inner {
    min-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0s linear var(--slow);
  }
  .stack__item.is-open .stack__inner {
    visibility: visible;
    transition-delay: 0s;
  }
  .stack__body {
    display: grid;
    grid-template-columns: clamp(120px, 22vw, 300px) minmax(0, 1fr);
    gap: var(--space-m);
    align-items: start;
  }
  .stack__picture {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-picture);
    background: var(--picture-ground);
  }
  .stack__text {
    max-width: 46rem;
    margin: 0;
    padding: var(--space-s) var(--edge) var(--space-l);
  }
  .stack__body .stack__text {
    padding-left: 0;
  }
  .stack__body {
    padding-left: var(--edge);
  }
  .stack__label {
    font-stretch: var(--width-label);
    margin-left: var(--gap);
  }
  .stack__label:first-child {
    margin-left: 0;
  }
  .stack__link {
    padding-block: 12px;
    color: var(--ink);
    text-decoration: none;
    background-clip: content-box;
    transition: color var(--quick) var(--ease), background-color var(--quick) var(--ease);
  }
  .stack__link:hover,
  .stack__link:focus-visible {
    color: var(--paper);
    background-color: var(--ink);
    outline: none;
  }

  @media (max-width: 40rem) {
    .stack__body {
      grid-template-columns: 1fr;
      padding-right: var(--edge);
    }
  }
</style>

<script>
(() => {
  for (const root of document.querySelectorAll('.stack')) {
    const items = [...root.querySelectorAll('.stack__item')];
    for (const item of items) {
      const toggle = item.querySelector('.stack__toggle');
      toggle.addEventListener('click', () => {
        const opening = !item.classList.contains('is-open');
        for (const other of items) {
          other.classList.remove('is-open');
          other.querySelector('.stack__toggle').setAttribute('aria-expanded', 'false');
        }
        if (opening) {
          item.classList.add('is-open');
          toggle.setAttribute('aria-expanded', 'true');
        }
      });
    }
  }
})();
</script>

Similar components

Bar and opening line

Bar and opening line

Wordmark masthead

Wordmark masthead

Header

Header

Masthead

Masthead

Corner nav

Corner nav

Grid top bar

Grid top bar

Doodle bar

Doodle bar

Grey index tiles

Grey index tiles