Try 'magnetic button'
View code

Number 56: Shimmer text

Specification

Catalogue
No. 56 of 110
Interaction
Loading, Text Animation
Element
Text
Preview
Live component
Imports
react 19.3.1
Added

Notes

A band in the full text colour sweeps across muted text while something is working. The text is painted with a gradient through background-clip: text, and the animation only moves background-position.

The gradient is mostly the muted text colour, with a narrow stop in the full text colour in the middle, and is sized at 260 percent so the band enters and leaves fully. On the entry page it runs four times and stops; it should never run longer than the work it stands for.

With reduced motion the text stays still in its muted colour.

Code

React and plain CSS
"use client";

import { useState, type CSSProperties } from "react";
import type { LivePreviewProps } from "@/components/live/types";
import styles from "./shimmer-text.module.css";

/** On the entry page the sweep runs a few times, then stops until replayed. */
const DETAIL_SWEEPS = 4;

export default function ShimmerText({ active, context }: LivePreviewProps) {
  const [run, setRun] = useState(0);
  const [running, setRunning] = useState(true);
  const playing = context === "card" ? active : running;
  const style = { "--sweeps": context === "card" ? "infinite" : String(DETAIL_SWEEPS) } as CSSProperties;

  return (
    <div className={styles.root}>
      <div className={styles.row}>
        <span className={styles.dot} data-running={playing || undefined} aria-hidden="true" />
        <p
          key={run}
          className={styles.text}
          data-running={playing || undefined}
          style={style}
          onAnimationEnd={() => setRunning(false)}
        >
          Reading the brief and drafting a reply
        </p>
      </div>
      <div className={styles.lines} aria-hidden="true">
        <span style={{ width: "88%" }} />
        <span style={{ width: "64%" }} />
      </div>
      {context === "detail" && (
        <button
          type="button"
          className={styles.replay}
          onClick={() => {
            setRun((r) => r + 1);
            setRunning(true);
          }}
        >
          Replay
        </button>
      )}
    </div>
  );
}

More like this

Transcript that follows the talk

Press, Text AnimationText and code

Sweeping headline phrase

Text AnimationText and code

Hand-drawn emphasis

Text AnimationText and code

Statement that reads with the scroll

Scroll, Text AnimationText and code

Dotted orb that thinks

Loading, AutoplayLoading and progress

Picture that resolves from a mosaic

LoadingLoading and progress