Gravity Headline
A headline with a word that changes. Each word falls into an unseen hole between the lines, stretching as it goes, and the next is thrown back out of it. It stays real text, so search, selection and screen readers all get words.
Included with membership
Members install Gravity Headline with one command and get the full source, the usage code and the Framer remix, licensed for client work. One membership covers the whole library and the CLI.
When to use it
The main headline of a landing page or a hero, where one word carries the message: what you make, who it is for, what it does. It suits short, bold words in a heavy face. Use one a page.
- Set the size, weight and colour on the heading with className, as you would for any headline. The falling words are drawn to match it.
- Start after with a line break to keep the changing word last on its line, so a longer word never pushes the rest of the headline down.
- Keep the colours you pass to colors at a similar lightness, so no word shouts over the others.
- Leave about 0.7em of room round the headline. Words move through it, and a parent that clips any closer cuts them off.
Avoid:
- Do not use gradient text or underlines on the heading. The falling words are drawn as plain text in one colour each.
- Do not count on a word wrapping. Each word stays on one line, so a long word in a narrow column overflows.
Props
A headline with a word that changes. When it is time for the next word, the one on screen falls into an unseen hole between the lines, its nearest letters first, so it stretches as it goes. The next word is then thrown back out of the hole, overshoots and settles into place. The hole is never drawn: it shows only by what it takes.
<GravityHeadline />
The headline, as real text, with a clear canvas over it that draws only while a word is moving.
| Prop | Type | Default | Description |
|---|---|---|---|
words* | string[] | — | The words that take turns, in order. Each stays on one line. |
before | string | — | The text before the changing word. A space is added between them unless you end with one. A "\n" breaks the line. |
after | string | — | The text after it. A space is added unless it starts with one or with punctuation. Start it with "\n" to keep the changing word last on its line, so a longer word never pushes the rest down. |
hold | number | 2.6 | How long each word stays before the next one, in seconds. |
as | "h1" | "h2" | "h3" | "p" | "h1" | The element the headline is. |
label | string | — | What screen readers hear instead of the moving headline. Default: the headline with every word, separated by commas. |
onWordChange | (index: number) => void | — | Called with the index of each word as it lands. |
className | string | — | On the heading itself: set its size, weight and colour here. Gradient text is not supported. |
style | React.CSSProperties | — | Inline styles on the heading. |
wordClassName | string | — | On the changing word, to style it apart from the rest of the headline. |
colors | string[] | — | A colour for each word, in the same order, as any CSS colour. They repeat when there are fewer than words. |