kitbash Sign in Connect agent
Components

Curved word band

A thick orange arc that sweeps across the page carrying a line of uppercase cream words that roll along the curve without end.

Part of the style

Tangerine Pill Parade

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

Preview

Code
<section class="band" aria-label="Fair prices, honest brakes, bells included, back by Friday">
  <svg class="band__svg" viewBox="0 0 1440 300" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
    <path id="band-arc" class="band__arc" d="M-80 290 C 320 120, 860 40, 1520 70" />
    <text class="band__text"><textPath class="band__words" href="#band-arc" startOffset="0">Fair prices • Honest brakes • Bells included • Back by Friday • </textPath></text>
  </svg>
</section>

<style>
  .band {
    position: relative;
    overflow: hidden;
    height: clamp(170px, 21vw, 300px);
    background: var(--cream);
  }
  .band__svg {
    position: absolute;
    left: 50%;
    top: 0;
    width: max(100%, 920px);
    height: auto;
    max-width: none;
    translate: -50% 0;
  }
  .band__arc {
    fill: none;
    stroke: var(--orange);
    stroke-width: 92px;
  }
  .band__text {
    fill: var(--shell);
    font-family: var(--font-display);
    font-stretch: var(--display-width);
    font-size: 50px;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    dominant-baseline: central;
  }
  @media (max-width: 600px) {
    .band { height: 150px; }
    .band__svg { top: -14px; }
  }
</style>

<script>
  (() => {
    for (const root of document.querySelectorAll('.band')) {
      const svg = root.querySelector('.band__svg');
      const words = root.querySelector('.band__words');
      const arc = root.querySelector('.band__arc');
      const phrase = words.textContent;
      let unit = 0;
      let offset = 0;
      let last = 0;
      let running = false;
      let frame = 0;
      const still = matchMedia('(prefers-reduced-motion: reduce)');

      const fill = () => {
        words.textContent = phrase;
        unit = words.getComputedTextLength();
        if (!unit) return;
        const copies = Math.ceil(arc.getTotalLength() / unit) + 1;
        words.textContent = phrase.repeat(copies);
      };

      const tick = (now) => {
        const step = last ? now - last : 0;
        last = now;
        offset -= (unit / 30000) * step;
        if (offset <= -unit) offset += unit;
        words.setAttribute('startOffset', offset.toFixed(1));
        frame = requestAnimationFrame(tick);
      };
      const start = () => {
        if (running || still.matches || !unit) return;
        running = true;
        last = 0;
        frame = requestAnimationFrame(tick);
      };
      const stop = () => {
        running = false;
        cancelAnimationFrame(frame);
      };

      (document.fonts ? document.fonts.ready : Promise.resolve()).then(() => {
        fill();
        new IntersectionObserver(([entry]) => (entry.isIntersecting ? start() : stop())).observe(root);
      });
      svg.addEventListener('mouseenter', stop);
      svg.addEventListener('mouseleave', start);
    }
  })();
</script>

Similar components

Pill arch

Pill arch

Activity band

Activity band

Earned-coins ticker

Earned-coins ticker

Red word band

Red word band

Tilted word ticker

Tilted word ticker

Discipline ticker and machine reel

Discipline ticker and machine reel

Drifting frames

Drifting frames

Blackletter news ticker

Blackletter news ticker