kitbash Sign in Connect agent
Components

City chips picture

One wide photograph with a row of white city pills over its lower edge; choosing a pill crossfades to that city's picture.

Part of the style

Kraft Panel Split

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --ink: #1e0b10;
  --ink-soft: #9d97a1;
  --paper: #f6f3f8;
  --paper-warm: #f0edf3;
  --field: #e8e4ea;
  --stone: #cfcad2;
  --kraft-deep: #4c393d;
  --veil: rgba(30, 11, 16, 0.5);
  --veil-soft: rgba(30, 11, 16, 0.2);
  --paper-glass: rgba(246, 243, 248, 0.52);
  --night: #210e13;
  --night-ink: #362327;
  --line: rgba(30, 11, 16, 0.08);
  --kraft: #d35456;
}
</style>

<section class="cities" aria-labelledby="cities-title">
  <div class="cities__head">
    <h2 class="cities__title" id="cities-title">Rooms by city</h2>
    <a class="cities__more" href="#">All cities</a>
  </div>
  <div class="cities__frame">
    <img class="cities__img is-current" src="assets/sunlit-parlour.jpg" alt="Sunlight on the wall of a pale parlour" width="1200" height="986">
    <img class="cities__img" src="assets/sitting-room.jpg" alt="A sitting room with red curtains and two windows" width="800" height="559">
    <img class="cities__img" src="assets/drawing-room.jpg" alt="A drawing room with columns and a bookcase" width="800" height="615">
    <img class="cities__img" src="assets/dining-room.jpg" alt="A panelled dining room with a long table" width="800" height="547">
    <div class="cities__chips" role="tablist" aria-label="Cities">
      <button class="cities__chip is-active" type="button" role="tab" aria-selected="true">Ghent</button>
      <button class="cities__chip" type="button" role="tab" aria-selected="false">Turin</button>
      <button class="cities__chip" type="button" role="tab" aria-selected="false">Kraków</button>
      <button class="cities__chip" type="button" role="tab" aria-selected="false">Bergen</button>
    </div>
  </div>
</section>

<style>
  .cities {
    padding: var(--section-space) var(--edge);
  }
  .cities__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-m);
    margin-bottom: var(--space-l);
  }
  .cities__title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: var(--text-l);
    font-weight: 400;
  }
  .cities__more {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--pill);
    background: var(--field);
    color: var(--ink);
    font-size: var(--text-s);
    font-weight: 500;
    text-decoration: none;
    transition: background var(--quick) var(--ease);
  }
  .cities__more:hover { background: var(--stone); }
  .cities__frame {
    position: relative;
    display: grid;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    border-radius: var(--radius-s);
    background: var(--paper-warm);
  }
  .cities__img {
    grid-area: 1 / 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--fade) var(--ease);
  }
  .cities__img.is-current { opacity: 1; }
  .cities__frame::after {
    content: "";
    grid-area: 1 / 1;
    background: linear-gradient(to top, var(--veil-soft), transparent 45%);
    pointer-events: none;
  }
  .cities__chips {
    position: absolute;
    z-index: 1;
    left: var(--space-m);
    right: var(--space-m);
    bottom: var(--space-m);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }
  .cities__chip {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--pill);
    background: var(--paper);
    color: var(--ink);
    font: 500 var(--text-s) var(--font-body);
    cursor: pointer;
    transition: background var(--quick) var(--ease), color var(--quick) var(--ease), transform 180ms var(--spring);
  }
  .cities__chip:hover { background: var(--field); }
  .cities__chip:active { transform: scale(0.94); }
  .cities__chip.is-active { background: var(--ink); color: var(--paper); }
  .cities a:focus-visible,
  .cities__chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

  @media (max-width: 40rem) {
    .cities__frame { aspect-ratio: 4 / 5; }
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.cities')) {
      const chips = [...root.querySelectorAll('.cities__chip')];
      const pictures = [...root.querySelectorAll('.cities__img')];
      chips.forEach((chip, index) => chip.addEventListener('click', () => {
        chips.forEach((other, i) => {
          other.classList.toggle('is-active', i === index);
          other.setAttribute('aria-selected', String(i === index));
        });
        pictures.forEach((picture, i) => picture.classList.toggle('is-current', i === index % pictures.length));
      }));
    }
  })();
</script>

Similar components

Featured tile rail

Featured tile rail

Latest work rail

Latest work rail

Loose project grid

Loose project grid

Badge carousel

Badge carousel

Bracketed Exhibits

Bracketed Exhibits

Line-screen archive

Line-screen archive

Creature deck

Creature deck

Project index

Project index