kitbash Sign in Connect agent
Components

Typed statement

One huge centred two-line statement that types itself in on view, with a floating dark pill counter in the corner.

Part of the style

Tile Ring Blackroom

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

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --night: #bb57f5;
  --night-raised: #a40ae4;
  --night-chip: #9516cf;
  --white: #121212;
  --card: #17150f;
  --ink: #bb57f5;
  --ash: #1e1600;
  --line: #8f19c6;
  --line-light: #231c07;
  --lime: #211802;
  --chartreuse: #1f1701;
  --mint: #211802;
  --sky: #211802;
}
</style>

<section class="statement">
  <h2 class="statement__text">
    <span class="statement__line">212+ varieties.</span>
    <span class="statement__line">New packet every week.</span>
  </h2>
  <p class="statement__counter" aria-hidden="true">Sown today <span class="statement__dot"></span> <span class="statement__count">038</span></p>
</section>

<style>
  .statement {
    position: relative;
    display: grid;
    place-items: center;
    min-height: clamp(420px, 50vw, 720px);
    padding: var(--section-space) var(--edge);
    background: var(--night);
    color: var(--white);
  }
  .statement__text {
    margin: 0;
    font: var(--weight) var(--display-xl)/var(--leading-tight) var(--font-display);
    letter-spacing: var(--track-tight);
    text-align: center;
  }
  .statement__line { display: block; }
  .statement__word { display: inline-block; white-space: nowrap; }
  .statement__char {
    color: var(--night-chip);
    transition: color var(--quick) ease;
  }
  .statement__char.is-typed { color: var(--white); }
  .statement__char.is-caret { box-shadow: inset -0.06em 0 0 var(--lime); }
  .statement__counter {
    position: absolute;
    right: var(--edge);
    bottom: var(--edge);
    display: flex;
    align-items: center;
    gap: var(--space-s);
    margin: 0;
    height: var(--control);
    padding: 0 24px;
    border-radius: var(--radius-pill);
    background: var(--night-chip);
    font: var(--weight) var(--text-s)/1 var(--font-mono);
    text-transform: uppercase;
  }
  .statement__dot {
    width: 6px;
    height: 6px;
    background: var(--lime);
  }
  .statement__count { font-variant-numeric: tabular-nums; }

  @media (max-width: 760px) {
    .statement__text { font-size: clamp(36px, 10vw, 56px); }
    .statement__counter { height: 40px; padding: 0 16px; font-size: var(--text-xs); }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)').matches;
  for (const root of document.querySelectorAll('.statement')) {
    const chars = [];
    for (const line of root.querySelectorAll('.statement__line')) {
      const text = line.textContent;
      line.setAttribute('aria-label', text);
      line.textContent = '';
      text.split(/(\s+)/).forEach((part) => {
        if (!part) return;
        if (/^\s+$/.test(part)) { line.append(part); return; }
        const word = document.createElement('span');
        word.className = 'statement__word';
        word.setAttribute('aria-hidden', 'true');
        for (const letter of part) {
          const span = document.createElement('span');
          span.className = 'statement__char';
          span.textContent = letter;
          word.append(span);
          chars.push(span);
        }
        line.append(word);
      });
    }
    const count = root.querySelector('.statement__count');
    const start = Number(count.textContent) || 0;
    const show = (n) => {
      chars.forEach((c, i) => {
        c.classList.toggle('is-typed', i < n);
        c.classList.toggle('is-caret', i === n - 1 && n < chars.length);
      });
      count.textContent = String(start + n).padStart(3, '0');
    };
    if (still) { show(chars.length); continue; }
    let timer = 0;
    let typed = 0;
    const run = () => {
      clearInterval(timer);
      timer = setInterval(() => {
        typed += 1;
        show(typed);
        if (typed >= chars.length) clearInterval(timer);
      }, 28);
    };
    new IntersectionObserver((entries) => {
      for (const entry of entries) {
        if (entry.isIntersecting && typed < chars.length) run();
        else clearInterval(timer);
      }
    }, { threshold: 0.3 }).observe(root);
  }
})();
</script>

Similar components

Quiet statement

Quiet statement

Night statement and figures

Night statement and figures

Read-through statement and figures

Read-through statement and figures

Window glimpse and statement

Window glimpse and statement

Statement with pills

Statement with pills

Loose statement

Loose statement

Matted diff feature

Matted diff feature

Getting there

Getting there