kitbash Sign in Connect agent
Components

Masthead

A centred two-line wordmark and motto over a left index of links in tan with the current one black; on phones the links fold into a 'Navigation ···' pill.

Part of the style

Faded Label Index

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #334493;
  --ink: #fff2f1;
  --ink-deep: #fffefe;
  --ink-faded: #6376b6;
  --tile: #fff3f2;
  --tile-ink: #334493;
  --flood: #a95858;
}
</style>

<header class="masthead">
  <a class="masthead__brand" href="#">
    <span class="masthead__name">Odd Hour</span>
    <span class="masthead__motto">Mending the mechanical hour</span>
  </a>

  <nav class="masthead__nav" aria-label="Sections">
    <button class="masthead__toggle" type="button" aria-expanded="false">
      <span class="masthead__toggle-word">Navigation</span>
      <span class="masthead__pill" aria-hidden="true"><span></span><span></span><span></span></span>
    </button>
    <p class="masthead__label">Navigation</p>
    <ul class="masthead__links">
      <li><a class="masthead__link is-current" href="#" aria-current="true">Bench</a></li>
      <li><a class="masthead__link" href="#">Repairs</a></li>
      <li><a class="masthead__link" href="#">Process</a></li>
      <li><a class="masthead__link" href="#">Rates</a></li>
      <li><a class="masthead__link" href="#">Notes</a></li>
      <li><a class="masthead__link" href="#">Contact</a></li>
    </ul>
  </nav>

  <p class="masthead__aside">
    <span class="masthead__label">Bench status</span>
    <span class="masthead__status">Taking spring commissions</span>
  </p>
</header>

<style>
  .masthead {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 var(--gap);
    align-items: start;
    padding: var(--edge);
    background: linear-gradient(var(--paper) 70%, transparent);
  }
  .masthead__brand {
    grid-column: 2 / 4;
    grid-row: 1;
    justify-self: center;
    display: grid;
    min-height: 44px;
    color: var(--ink);
    text-align: center;
    text-decoration: none;
  }
  .masthead__name {
    font-weight: 500;
  }
  .masthead__nav {
    grid-column: 1;
    grid-row: 1;
  }
  .masthead__label {
    margin: 0;
    color: var(--ink-faded);
  }
  .masthead__links {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .masthead__link {
    display: inline;
    color: var(--ink-faded);
    text-decoration: none;
    transition: color var(--time) var(--ease);
  }
  .masthead__link:hover,
  .masthead__link:focus-visible,
  .masthead__link.is-current {
    color: var(--ink);
  }
  .masthead__link:focus-visible,
  .masthead__brand:focus-visible,
  .masthead__toggle:focus-visible {
    outline: var(--line) solid var(--ink);
    outline-offset: 2px;
  }
  .masthead__aside {
    grid-column: 4;
    grid-row: 1;
    display: grid;
    margin: 0;
    text-align: right;
  }
  .masthead__toggle {
    display: none;
  }

  @media (min-width: 761px) {
    .masthead__nav .masthead__label {
      display: none;
    }
    .masthead__link {
      padding: 0;
    }
  }

  @media (max-width: 760px) {
    .masthead {
      grid-template-columns: minmax(0, 1fr);
      justify-items: center;
      gap: 0;
    }
    .masthead__brand,
    .masthead__nav,
    .masthead__aside {
      grid-column: 1;
      grid-row: auto;
    }
    .masthead__aside {
      display: none;
    }
    .masthead__nav {
      display: grid;
      justify-items: center;
      width: 100%;
    }
    .masthead__nav > .masthead__label {
      display: none;
    }
    .masthead__toggle {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      min-height: 44px;
      padding: 0;
      border: 0;
      background: none;
      color: var(--ink);
      font: inherit;
      letter-spacing: inherit;
      cursor: pointer;
    }
    .masthead__pill {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 3px;
      width: 36px;
      height: 16px;
      border-radius: 8px;
      background: color-mix(in srgb, var(--ink-faded) 45%, var(--paper));
      transition: background-color var(--quick) var(--ease);
    }
    .masthead__pill span {
      width: 3px;
      height: 3px;
      border-radius: 50%;
      background: var(--ink);
      transition: transform var(--quick) var(--ease), opacity var(--quick) var(--ease);
    }
    .masthead.is-open .masthead__pill span:nth-child(1) {
      transform: translateX(6px) scaleX(4) rotate(45deg);
      border-radius: 0;
    }
    .masthead.is-open .masthead__pill span:nth-child(2) {
      opacity: 0;
    }
    .masthead.is-open .masthead__pill span:nth-child(3) {
      transform: translateX(-6px) scaleX(4) rotate(-45deg);
      border-radius: 0;
    }
    .masthead__links {
      display: none;
      width: 100%;
      padding: var(--space-s) 0 var(--space-s);
      font-size: var(--text-phone);
      line-height: var(--leading-phone);
    }
    .masthead.is-open .masthead__links {
      display: grid;
    }
    .masthead__link {
      display: flex;
      align-items: center;
      min-height: 44px;
    }
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.masthead')) {
      const toggle = root.querySelector('.masthead__toggle');
      if (!toggle) continue;
      toggle.addEventListener('click', () => {
        const open = root.classList.toggle('is-open');
        toggle.setAttribute('aria-expanded', String(open));
      });
      for (const link of root.querySelectorAll('.masthead__link')) {
        link.addEventListener('click', () => {
          for (const other of root.querySelectorAll('.masthead__link')) {
            other.classList.toggle('is-current', other === link);
            other.toggleAttribute('aria-current', other === link);
          }
        });
      }
    }
  })();
</script>

Similar components

Bar and opening line

Bar and opening line

Grid top bar

Grid top bar

Grey index tiles

Grey index tiles

Word stack

Word stack

Spread nav with mascot

Spread nav with mascot

Floating dock

Floating dock

Floating chip bar

Floating chip bar

Corner masthead

Corner masthead