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.
Free. Create a free account to copy the source. Read the release note
Diff Headline
Live preview
Ship the ritual.
Press Next line, or type your own line and ship it.
Sign in free to see the code
Every file of Diff Headline, ready to copy. Free account, free forever. You come straight back here.
Get it into your app
Three steps. Copy the files and you're done; nothing to install.
SoonCLI and MCP install
Step 1: Get it
The source is free with an account, free forever. You come straight back to this page.
Step 2: Add it
Paste the files into
src/components/motionbits/, keeping the paths.diff-headline/diff-headline.tsxdiff-headline/diff-headline.cssdiff-headline/diff.tsquarter-turn.tsdiff-headline/index.ts
Needs react and react-dom. No other packages to install.
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
| Prop | Type | Default | What it does |
|---|---|---|---|
lines | string[] | — | The headlines, in the order they cycle. Only the words that differ are struck and replaced. |
value / defaultValue | number | 0 | Controlled or uncontrolled index of the line shown. |
onValueChange | (index: number) => void | — | Called when an edit starts. |
interval | number | 0 | Milliseconds between automatic edits. 0 leaves it manual. |
as | "h1" | "h2" | "h3" | "p" | "div" | "h2" | The element the headline renders as. |
tag | string | false | "+1" | The tag that pops after each edit. false hides it and the gutter. |
ref | DiffHeadlineHandle | — | 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.