Skip to content
Motionbits

Headlines and release pagesFreeNew

Diff Headline

Your headline, shipped like a commit. A thick cut strikes the old words, they tip off the line, and the new words rise in, with a diff gutter and a +1 tag marking the change.

Get the code for Diff Headline
Save Diff Headline: sign in first

Free. Create a free account to copy the source. Read the release note

Diff Headline

Component 04 · React + WAAPI

Live preview

Ship the ritual.

Press Next line, or type your own line and ship it.

Get it into your app

Three steps. Copy the files and you're done; nothing to install.

SoonCLI and MCP install

  1. Step 1: Get it

    The source is free with an account, free forever. You come straight back to this page.

  2. Step 2: Add it

    Paste the files into src/components/motionbits/, keeping the paths.

    • diff-headline/diff-headline.tsx
    • diff-headline/diff-headline.css
    • diff-headline/diff.ts
    • quarter-turn.ts
    • diff-headline/index.ts

    Needs react and react-dom. No other packages to install.

  3. Step 3: Use it

    Import it and drop it in. Usage and props are just below.

    import { DiffHeadline } from "@/components/motionbits/diff-headline";

Usage

import { DiffHeadline } from "@/components/motionbits/diff-headline";
 
export function Hero() {
  return (
    <DiffHeadline
      as="h1"
      lines={["Ship the ritual.", "Ship the release.", "Ship it today."]}
      interval={4000}
    />
  );
}
 
// Or drive it yourself:
const [i, setI] = useState(0);
<DiffHeadline lines={lines} value={i} onValueChange={setI} />;

Props

Diff Headline props
PropTypeDefaultWhat it does
linesstring[]—The headlines, in the order they cycle. Only the words that differ are struck and replaced.
value / defaultValuenumber0Controlled or uncontrolled index of the line shown.
onValueChange(index: number) => void—Called when an edit starts.
intervalnumber0Milliseconds between automatic edits. 0 leaves it manual.
as"h1" | "h2" | "h3" | "p" | "div""h2"The element the headline renders as.
tagstring | false"+1"The tag that pops after each edit. false hides it and the gutter.
refDiffHeadlineHandle—goTo(index, { seekMs }), next() and reset(index).

Accessibility

  • The animated letters are hidden from assistive technology. A visually hidden copy always holds the full current line.
  • That copy is announced politely only when the headline is driven manually, so an automatic cycle never talks over the reader.
  • Every variant is laid out in the same box, so the height never changes and nothing below the headline moves.

Motion

  • The cut is a 0.12em accent bar that sweeps left to right in 450ms across the struck words.
  • Each struck word tips about its bottom-right corner and falls out of the line (fade and 40° rotation, 30ms stagger).
  • The new words rise character by character through word masks, 20ms a character. The gutter flashes and the +1 tag pops.
  • With reduced motion the headline fades to the new line (0.12s out, 0.2s in), and the automatic cycle is paused.