kitbash Sign in Connect agent
Components

Word-by-word testimonial

A very large tight quote whose words fill from grey to black one by one, with round arrow buttons, a 01/05 counter, a stat on the left and the author with a drawn avatar. Five slides, cross-fading, autoplaying in view.

Part of the style

Clothesline Pitch

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --paper: #9d9485;
  --white: #a2998a;
  --ink: #07150a;
  --ink-soft: #19271b;
  --grey: #243126;
  --grey-light: #a49a8a;
  --dim: rgba(7, 21, 10, 0.45);
  --unread: rgba(7, 21, 10, 0.14);
  --unread-dark: rgba(162, 153, 138, 0.22);
  --soft-dark: rgba(162, 153, 138, 0.45);
  --line: rgba(7, 21, 10, 0.2);
  --line-dark: rgba(162, 153, 138, 0.14);
  --night: #061208;
  --card-black: #07150a;
  --panel: #1e2c20;
  --chip: #223125;
  --edge-dark: #263428;
  --menu-edge: #2e3d31;
  --lime: #2d9148;
  --lime-ink: #000000;
  --sun: #4c925a;
  --live: #3e9653;
  --blue: #609069;
  --pink: #558d64;
  --pink-ink: #000000;
  --orange: #05451b;
  --violet: #609069;
}
</style>

<section class="testimonials" aria-label="What clients say" aria-roledescription="carousel">
  <div class="testimonials__side">
    <span class="testimonials__progress" aria-hidden="true"><span class="testimonials__progress-fill"></span></span>
    <div class="testimonials__controls">
      <div class="testimonials__arrows">
        <button class="testimonials__arrow" type="button" data-step="-1" aria-label="Previous quote"><svg class="testimonials__arrow-ico" viewBox="0 0 20 20" aria-hidden="true"><path d="M16 10H4m5-5-5 5 5 5"/></svg></button>
        <button class="testimonials__arrow" type="button" data-step="1" aria-label="Next quote"><svg class="testimonials__arrow-ico" viewBox="0 0 20 20" aria-hidden="true"><path d="M4 10h12m-5-5 5 5-5 5"/></svg></button>
      </div>
      <p class="testimonials__counter"><span class="testimonials__current">01</span>/<span class="testimonials__total">05</span></p>
    </div>
    <div class="testimonials__stat">
      <p class="testimonials__stat-num">40+</p>
      <p class="testimonials__stat-text">Sites shipped,<br>from bakeries to boatyards</p>
    </div>
  </div>

  <div class="testimonials__slides" aria-live="polite">
    <figure class="testimonials__slide is-active">
      <blockquote class="testimonials__quote">“Otto rebuilt our booking site in three weeks. Guests stopped emailing to ask if rooms were free and started just booking them. Best money we spent all winter.”</blockquote>
      <figcaption class="testimonials__who">
        <svg class="testimonials__avatar" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="22" fill="#05080c"/><circle cx="22" cy="21" r="9" fill="#ff7a3d"/><path d="M8 26h28M11 30h22M15 34h14" stroke="#2e90fa" stroke-width="2.4" stroke-linecap="round"/></svg>
        <span class="testimonials__name">Ada Moerman</span>
        <span class="testimonials__role">Owner at <a class="testimonials__link" href="#">Brine House</a></span>
      </figcaption>
    </figure>
    <figure class="testimonials__slide">
      <blockquote class="testimonials__quote">“He asked better questions about our pots than our customers do. The shop finally feels like the studio smells: warm, a little odd and very us.”</blockquote>
      <figcaption class="testimonials__who">
        <svg class="testimonials__avatar" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="22" fill="#05080c"/><circle cx="22" cy="25" r="10" fill="#ff7ac6"/><rect x="18" y="10" width="8" height="6" rx="2" fill="#ff7ac6"/><path d="M32 22c4 0 4 6 0 6" stroke="#ff7ac6" stroke-width="2.4" fill="none"/></svg>
        <span class="testimonials__name">Jun Okafor</span>
        <span class="testimonials__role">Maker at <a class="testimonials__link" href="#">Odd Pot</a></span>
      </figcaption>
    </figure>
    <figure class="testimonials__slide">
      <blockquote class="testimonials__quote">“Clear plan, honest price, no mystery invoices. The site went live on the day he said it would, which in our trade is basically a miracle.”</blockquote>
      <figcaption class="testimonials__who">
        <svg class="testimonials__avatar" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="22" fill="#05080c"/><rect x="11" y="13" width="9" height="19" fill="#c6f432"/><rect x="24" y="13" width="9" height="19" fill="#c6f432"/></svg>
        <span class="testimonials__name">Rosa Kint</span>
        <span class="testimonials__role">Partner at <a class="testimonials__link" href="#">Two Doors</a></span>
      </figcaption>
    </figure>
    <figure class="testimonials__slide">
      <blockquote class="testimonials__quote">“Guests write about our website in the cabin guest books now. Nobody in history has ever written about a website in a guest book.”</blockquote>
      <figcaption class="testimonials__who">
        <svg class="testimonials__avatar" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="22" fill="#05080c"/><path d="M22 8 13 24h5l-6 10h20l-6-10h5z" fill="#c6f432"/></svg>
        <span class="testimonials__name">Pieter Vos</span>
        <span class="testimonials__role">Host at <a class="testimonials__link" href="#">Hollow Pine</a></span>
      </figcaption>
    </figure>
    <figure class="testimonials__slide">
      <blockquote class="testimonials__quote">“Fast, funny and allergic to templates. I would hire him again tomorrow. I did, twice, and the second site was even better.”</blockquote>
      <figcaption class="testimonials__who">
        <svg class="testimonials__avatar" viewBox="0 0 44 44" aria-hidden="true"><circle cx="22" cy="22" r="22" fill="#05080c"/><path d="M22 9l3.5 8.5 9 .5-7 5.8 2.4 8.8L22 27.5l-7.9 5.1 2.4-8.8-7-5.8 9-.5z" fill="#ffd23f"/></svg>
        <span class="testimonials__name">Lena Haas</span>
        <span class="testimonials__role">Founder at <a class="testimonials__link" href="#">Kettle &amp; Co</a></span>
      </figcaption>
    </figure>
  </div>
</section>

<style>
  .testimonials {
    --hold: 8s;
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    gap: clamp(32px, 7vw, 95px);
    padding: var(--section-space) var(--edge);
    background: var(--paper);
    color: var(--ink);
  }
  .testimonials__side { display: flex; flex-direction: column; gap: 32px; }
  .testimonials__progress { display: block; height: 2px; background: var(--unread); overflow: hidden; }
  .testimonials__progress-fill { display: block; width: 0; height: 100%; background: var(--ink); }
  .testimonials.is-playing .testimonials__progress-fill { animation: testimonials-fill var(--hold) linear forwards; }
  .testimonials.is-held .testimonials__progress-fill { animation-play-state: paused; }
  .testimonials__controls { display: flex; align-items: center; justify-content: space-between; }
  .testimonials__arrows { display: flex; gap: 6px; margin-left: -6px; }
  .testimonials__arrow {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--quick), color var(--quick);
  }
  .testimonials__arrow:hover { background: var(--ink); color: var(--white); }
  .testimonials__arrow:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
  .testimonials__arrow-ico { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .testimonials__counter { margin: 0; color: var(--dim); font: 500 var(--text-mono)/1.2 var(--font-mono); }
  .testimonials__current { color: var(--ink); }
  .testimonials__stat-num { margin: 0; font: 600 var(--text-stat)/1 var(--font-tight); letter-spacing: -0.06em; }
  .testimonials__stat-text { margin: 8px 0 0; color: var(--grey); font-size: var(--text-xs); line-height: 1.35; }

  .testimonials__slides { display: grid; }
  .testimonials__slide {
    grid-area: 1 / 1;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s, visibility 0s 0.4s;
  }
  .testimonials__slide.is-active { opacity: 1; visibility: visible; transition: opacity 0.4s; }
  .testimonials__quote {
    margin: 0;
    font: 600 var(--text-quote)/1.05 var(--font-tight);
    letter-spacing: -0.045em;
    color: var(--unread);
  }
  .testimonials__word { color: var(--unread); transition: color var(--word) ease calc(var(--i) * var(--word-step)); }
  .testimonials__slide.is-lit .testimonials__word { color: var(--ink); }
  .testimonials__who {
    display: grid;
    grid-template-columns: 44px auto;
    column-gap: 12px;
    align-items: center;
    margin-top: 40px;
  }
  .testimonials__avatar { grid-row: span 2; width: 44px; height: 44px; transition: transform var(--lift) var(--spring); }
  .testimonials__who:hover .testimonials__avatar { transform: rotate(-12deg) scale(1.1); }
  .testimonials__name { font: 500 17px/1.2 var(--font-tight); letter-spacing: -0.02em; }
  .testimonials__role { color: var(--grey); font-size: var(--text-s); line-height: 1.2; }
  .testimonials__link { color: inherit; text-underline-offset: 3px; }
  .testimonials__link:hover { color: var(--ink); }

  @keyframes testimonials-fill { to { width: 100%; } }

  @media (max-width: 760px) {
    .testimonials { grid-template-columns: 1fr; gap: 28px; }
    .testimonials__side { display: contents; }
    .testimonials__progress { order: 1; }
    .testimonials__controls { order: 2; margin-top: -12px; }
    .testimonials__slides { order: 3; }
    .testimonials__stat { order: 4; padding-top: 24px; border-top: 1px solid var(--unread); }
  }
  @media (prefers-reduced-motion: reduce) {
    .testimonials__word { transition: none; color: var(--ink); }
    .testimonials__progress { display: none; }
  }
</style>

<script>
(() => {
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
  const pad = (n) => String(n).padStart(2, '0');

  function splitWords(quote) {
    const words = quote.textContent.trim().split(/\s+/);
    quote.replaceChildren(...words.flatMap((word, i) => {
      const span = document.createElement('span');
      span.className = 'testimonials__word';
      span.style.setProperty('--i', i);
      span.textContent = word;
      return i ? [' ', span] : [span];
    }));
  }

  function setUp(root) {
    const slides = [...root.querySelectorAll('.testimonials__slide')];
    const current = root.querySelector('.testimonials__current');
    const fill = root.querySelector('.testimonials__progress-fill');
    const hold = parseFloat(getComputedStyle(root).getPropertyValue('--hold')) * 1000 || 8000;
    let index = 0;
    let inView = false;
    let held = false;
    let timer = null;

    root.querySelector('.testimonials__total').textContent = pad(slides.length);
    root.querySelectorAll('.testimonials__quote').forEach(splitWords);

    function restartProgress() {
      root.classList.remove('is-playing');
      void fill.offsetWidth;
      if (inView && !reduced) root.classList.add('is-playing');
    }

    function schedule() {
      clearTimeout(timer);
      if (inView && !held && !reduced) timer = setTimeout(() => show(index + 1), hold);
    }

    function show(next) {
      slides[index].classList.remove('is-active', 'is-lit');
      index = (next + slides.length) % slides.length;
      const slide = slides[index];
      slide.classList.add('is-active');
      requestAnimationFrame(() => requestAnimationFrame(() => slide.classList.add('is-lit')));
      current.textContent = pad(index + 1);
      restartProgress();
      schedule();
    }

    root.querySelectorAll('.testimonials__arrow').forEach((arrow) => {
      arrow.addEventListener('click', () => show(index + Number(arrow.dataset.step)));
    });

    function setHeld(on) {
      held = on;
      root.classList.toggle('is-held', on);
      if (on) return clearTimeout(timer);
      restartProgress();
      schedule();
    }
    root.addEventListener('pointerenter', () => setHeld(true));
    root.addEventListener('pointerleave', () => setHeld(false));
    root.addEventListener('focusin', () => setHeld(true));
    root.addEventListener('focusout', () => setHeld(false));

    new IntersectionObserver(([entry]) => {
      inView = entry.isIntersecting;
      if (inView) slides[index].classList.add('is-lit');
      restartProgress();
      inView ? schedule() : clearTimeout(timer);
    }, { threshold: 0.3 }).observe(root);
  }

  document.querySelectorAll('.testimonials').forEach(setUp);
})();
</script>

Similar components

Pink voice card

Pink voice card

Timed reviews

Timed reviews

Slab quote

Slab quote

Press quote

Press quote

Film player

Film player

Flavour picker

Flavour picker

Instrument panel

Instrument panel

Ledger

Ledger