kitbash Sign in Connect agent
Components

Book shelf

Bold label with a light subhead, then a sideways track of book views: the cover on a green square and printed page spreads, moved with an outlined back circle and a black next circle.

Part of the style

Graph Paper Novel

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --page: #ff48a4;
  --grid-line: #eb4598;
  --ink: #121212;
  --ink-soft: #552636;
  --ink-dim: #cb4084;
  --panel: #f3469d;
  --sheet: #ff7db6;
  --on-dark: #32021b;
  --metal-light: #fe5da9;
  --metal-mid: #ad3a71;
  --metal-dark: #48232f;
  --shade: rgba(18, 18, 18, 0.3);
  --shade-light: rgba(18, 18, 18, 0.1);
  --sheen: rgba(254, 110, 175, 0.1);
  --green: #de4b92;
  --green-hover: #3e0022;
  --scribble: #b96e8d;
}
</style>

<section class="shelf" aria-labelledby="shelf-title">
  <div class="shelf__head">
    <h2 class="shelf__title" id="shelf-title">The Book</h2>
    <p class="shelf__subtitle">4 Languages. 3 Formats. One Course.</p>
  </div>

  <div class="shelf__track" tabindex="0" aria-label="Views of the book">
    <figure class="shelf__slide">
      <div class="shelf__panel">
        <div class="shelf__book">
          <span class="shelf__book-title">True<br>North</span>
          <svg class="shelf__book-mark" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 4l2.5 8h-5zM12 20l2.5-8h-5z"/></svg>
          <span class="shelf__book-author">Ines Calloway</span>
        </div>
      </div>
      <figcaption class="shelf__caption">Hardcover, 312 pages</figcaption>
    </figure>

    <figure class="shelf__slide">
      <div class="shelf__page">
        <p class="shelf__page-head">One. Slack Water</p>
        <p>Nell Varga learned the harbour before she learned to read. She knew which buoys leaned after a storm, which moorings were rented and which were simply taken, and that her father checked the tide table twice because he did not trust himself once.</p>
        <p>The night he did not come back, she sat at the kitchen table with his pencil and his chart and tried to work out where a small boat goes when nobody is steering it.</p>
        <p><em>You never know where you are,</em> he used to say. <em>You only know where you were, and how long you have been going.</em></p>
        <p>It took her eleven years to understand that he had not been talking about the sea.</p>
        <span class="shelf__folio">9</span>
      </div>
      <figcaption class="shelf__caption">Opening page</figcaption>
    </figure>

    <figure class="shelf__slide">
      <div class="shelf__page shelf__page--contents">
        <p class="shelf__page-head">Contents</p>
        <ol class="shelf__toc">
          <li><span>Slack Water</span><span>9</span></li>
          <li><span>The Tide Table</span><span>31</span></li>
          <li><span>Leeway</span><span>58</span></li>
          <li><span>A Borrowed Mooring</span><span>87</span></li>
          <li><span>Fog Signal</span><span>120</span></li>
          <li><span>Set and Drift</span><span>163</span></li>
          <li><span>The Fix</span><span>204</span></li>
          <li><span>Making Port</span><span>271</span></li>
        </ol>
      </div>
      <figcaption class="shelf__caption">Contents</figcaption>
    </figure>

    <figure class="shelf__slide">
      <div class="shelf__panel">
        <div class="shelf__book shelf__book--back">
          <p class="shelf__blurb">A daughter, a lost boat and eleven years of learning to say <em>here I am</em> with nothing but a pencil and a clock.</p>
        </div>
      </div>
      <figcaption class="shelf__caption">Back cover</figcaption>
    </figure>
  </div>

  <div class="shelf__controls">
    <button class="shelf__button shelf__button--back" type="button" aria-label="Previous view" disabled>
      <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M16 10H4M9 5l-5 5 5 5"/></svg>
    </button>
    <button class="shelf__button shelf__button--next" type="button" aria-label="Next view">
      <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 10h12M11 5l5 5-5 5"/></svg>
    </button>
  </div>
</section>

<style>
  .shelf {
    display: grid;
    gap: var(--space-m);
    padding: var(--space-l) var(--edge) var(--section-space);
  }
  .shelf__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem var(--space-m);
  }
  .shelf__title {
    margin: 0;
    font-size: var(--text-m);
    font-weight: 600;
  }
  .shelf__subtitle {
    margin: 0;
    font-size: var(--text-m);
    font-weight: 300;
  }
  .shelf__track {
    display: flex;
    gap: var(--space-m);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }
  .shelf__track::-webkit-scrollbar { display: none; }
  .shelf__track:focus-visible { outline: var(--rule) solid var(--green); outline-offset: 0.25rem; }
  .shelf__slide {
    flex: none;
    width: clamp(15rem, 34vw, 26rem);
    margin: 0;
    scroll-snap-align: start;
  }
  .shelf__panel {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    background:
      linear-gradient(to bottom, transparent 72%, var(--shade-light) 72%),
      var(--green);
  }
  .shelf__book {
    position: relative;
    width: 46%;
    aspect-ratio: 2 / 3;
    display: grid;
    justify-items: center;
    align-content: space-between;
    padding: 14% 8% 10%;
    background:
      linear-gradient(to right, var(--shade), transparent 7%, var(--sheen) 9%, transparent 14%),
      var(--green);
    box-shadow: 0.6rem 0.9rem 1.2rem var(--shade), inset 0 0 0 var(--rule) var(--sheen);
    color: var(--on-dark);
    text-align: center;
  }
  .shelf__book-title {
    font: 400 clamp(1.5rem, 3.4vw, 2.5rem) / 0.9 var(--font-display);
    text-transform: uppercase;
    letter-spacing: var(--tracking-display);
  }
  .shelf__book-mark {
    width: 26%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
  }
  .shelf__book-author { font-size: var(--text-xs); font-style: italic; }
  .shelf__book--back { place-items: center; }
  .shelf__blurb {
    margin: 0;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    font-weight: 300;
    line-height: 1.35;
  }
  .shelf__page {
    position: relative;
    aspect-ratio: 1;
    padding: 9% 11%;
    border-radius: var(--radius-card);
    background:
      linear-gradient(to right, var(--shade-light), transparent 6%),
      var(--sheet);
    box-shadow: 0 0.5rem 1rem var(--shade-light);
    color: var(--ink-soft);
    font-size: clamp(0.6rem, 0.9vw, 0.78rem);
    font-weight: 400;
    line-height: 1.45;
    text-align: justify;
    hyphens: auto;
    overflow: hidden;
  }
  .shelf__page p { margin: 0 0 0.7em; }
  .shelf__page-head {
    margin-bottom: 1.4em !important;
    font-style: italic;
    text-align: left;
  }
  .shelf__folio {
    position: absolute;
    bottom: 6%;
    left: 50%;
  }
  .shelf__toc {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .shelf__toc li {
    display: flex;
    justify-content: space-between;
    gap: 1em;
    padding: 0.55em 0;
    border-bottom: var(--rule) solid var(--grid-line);
  }
  .shelf__caption {
    margin-top: var(--space-xs);
    color: var(--ink-soft);
    font: 400 var(--text-xs) var(--font-label);
    letter-spacing: 0;
  }
  .shelf__controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
  }
  .shelf__button {
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    border: var(--rule) solid var(--ink);
    border-radius: 50%;
    background: var(--ink);
    color: var(--on-dark);
    cursor: pointer;
    transition: opacity var(--quick) ease, background-color var(--quick) ease;
  }
  .shelf__button--back { background: transparent; color: var(--ink); }
  .shelf__button:disabled { opacity: 0.3; cursor: default; }
  .shelf__button:not(:disabled):hover { background: var(--green); border-color: var(--green); color: var(--on-dark); }
  .shelf__button svg {
    width: 1.1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
  }

  @media (prefers-reduced-motion: reduce) {
    .shelf__track { scroll-behavior: auto; }
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.shelf')) {
      const track = root.querySelector('.shelf__track');
      const back = root.querySelector('.shelf__button--back');
      const next = root.querySelector('.shelf__button--next');
      const step = () => track.querySelector('.shelf__slide').offsetWidth + parseFloat(getComputedStyle(track).columnGap || 0);

      const updateButtons = () => {
        back.disabled = track.scrollLeft < 4;
        next.disabled = track.scrollLeft + track.clientWidth > track.scrollWidth - 4;
      };

      back.addEventListener('click', () => track.scrollBy({ left: -step() }));
      next.addEventListener('click', () => track.scrollBy({ left: step() }));
      track.addEventListener('scroll', updateButtons, { passive: true });
      new ResizeObserver(updateButtons).observe(track);
    }
  })();
</script>

Similar components

Collage stage

Collage stage

Picture collage

Picture collage

Feed row

Feed row

Poster rail

Poster rail

Project windows

Project windows

Inset project tiles

Inset project tiles

Lineup tiles

Lineup tiles

Work grid with pill

Work grid with pill