Skip to content
animorio
IT
Back to the library

Rotating word headline

TextGSAP, CSS onlyMediumCompressed weight: Demo 5.6 KBGSAP 28 KBFreeDownload the zip

The hero of a design to code handoff tool, on white: the big headline ends with a word inside a tinted pill that rolls into the next one every two seconds, letter by letter, the old letters leaving at the top and the new ones climbing in from below, while the pill stretches or shrinks on a spring and slightly changes colour. Below, the subtitle and the two buttons.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN.

<!doctype html>
<!--
  "Rotating word headline" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The headline with a rotating word</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the hero of a made-up design handoff tool: the headline ends with a word in a tinted pill that rolls to the
         next one every two seconds, the pill stretching to fit it while the rest of the line makes room -->
    <section class="hero" data-hero aria-label="Handwell">
      <a class="pill" href="#" data-pill>
        <span class="pill__tag">Handwell 3</span>
        <span class="pill__text">Handoff, rebuilt</span>
        <svg class="pill__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M5.5 3.5 10 8l-4.5 4.5"></path></svg>
      </a>

      <h1 class="title" data-title>
        <span class="title__line" data-line>Ship faster</span>
        <span class="title__line" data-line>with your <span class="rotor" data-rotor tabindex="0" aria-live="polite"><span class="rotor__track" data-track></span><span class="rotor__time" data-time aria-hidden="true"></span></span></span>
      </h1>
      <span class="misura title" data-measure aria-hidden="true"></span>

      <p class="sub" data-sub>Handwell turns every design into specs, tokens and code your whole team can build from, the same afternoon.</p>

      <div class="actions" data-actions>
        <a class="btn btn--primary" href="#" data-btn>
          <span class="btn__label">Try it free</span>
          <svg class="btn__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.5 4 12.5 8l-4 4"></path></svg>
        </a>
        <a class="btn btn--ghost" href="#" data-btn>
          <span class="btn__label">See how it works</span>
        </a>
      </div>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

17 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Rotating word headline” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On a white background, with a barely visible glow in the word’s colour behind the middle, sits the opening of the page of Handwell, a made-up tool that turns designs into measurements, colours and code for whoever has to build them. First the release pill comes in, Handwell 3 in black and Handoff, rebuilt in grey, then the big headline on two lines, Ship faster with your, and at the end of the second line a word inside a tinted pill, designers. Every two seconds the word changes: its letters roll upwards and disappear one after the other, those of the new word climb in from below, staggered, go slightly above the line and settle. Meanwhile the pill stretches or shrinks to the new word’s width on a spring, with a small breath as the word lands, and the rest of the line slides to make room. The colour goes from violet to indigo, then to blue and teal: designers, engineers, founders, whole team. A thin line along the bottom of the pill fills up until the next change. Below, the grey subtitle and two buttons, a black Try it free with its arrow and a white See how it works with its border. After the last word the hero slips away upwards and starts over. With the mouse over the pill the word holds and the pill lifts a pixel; a click, or Enter, moves straight to the next word.

How it works

One word, a row of letters

Each word is a span with one span per letter, positioned absolutely inside the pill: this way the old and the new can share the space for a few tenths of a second, one leaving and one arriving, without pushing each other.

The rolling letters

The old letters go to yPercent minus 115 with power3.in, LETTER_STAGGER seconds apart; the new ones start from 115 and reach 0 with the keyframes 115, minus 9, 2.5, 0 in 0.62 seconds with power3.out. The step to minus 9 is the extra pixel that makes them feel sprung. The pill has overflow hidden: the letters vanish at its edge.

The pill that measures itself

The new word’s width is measured on a hidden twin of the headline, with the same typeface and size, plus 0.44 em of padding. GSAP takes the pill to that width with back.out(SPRING): the headline is centred, so the rest of the line slides by itself to make room.

Colour without color-mix

For each word the script computes from its colour the fill at 10% and the edge at 24% and writes them into three CSS variables; the pill has a 0.6 second transition on fill and colour, and the glow behind the headline uses the same variable.

Time you can pause

The change is made by a gsap.delayedCall of INTERVAL seconds, not a timeline: with the mouse over the pill the countdown and the filling line pause, and a click moves straight to the next word. After the last word the hero leaves and comes back from the start.

Values to change

NameFileDefaultWhat it changes
WORDSscript.js'designers|engineers|founders|whole team'The words that take turns in the pill, separated by a vertical bar.
COLORSscript.js'#6d28d9|#4f46e5|#0369a1|#0f766e'The pill’s colour for each word, in the same order.
INTERVALscript.js2The seconds between one word and the next.
LETTER_STAGGERscript.js0.032The seconds between one letter and the next as they roll.
SPRINGscript.js1.7How much the pill bounces as it stretches or shrinks (0 means no bounce).
HOLDscript.js1.6The extra seconds on the last word before the hero starts over.

Try them in the Playground

When to use it

For the opening of the landing page of a piece of software, an app or a service that speaks to different people: one sentence that adapts to whoever reads it (designers, engineers, founders, the whole team) without writing four headlines. It also suits the header of a pricing page or an announcement.

On phones

The same animation with adapted sizes: the headline is measured on the width and height of the screen and stays on two lines, the pill is measured again for every word and the buttons wrap if needed. A tap on the pill moves to the next word.

With reduced motion

No rolling letters, no spring and no rising: the words take turns with a cross-fade, the pill takes the new width at once and the colour changes gently; the hero fades in.

Pitfalls

  • The width must be measured on an element with the same font-size, weight, width axis and letter-spacing as the headline: measured on the pill itself, while the old word is still there, it comes out wrong.
  • The words inside the pill are absolutely positioned: in the flow, the new word would push the old one aside halfway through the change.
  • The change is a delayedCall and not a repeating timeline, so it can pause on hover and skip ahead on click without rebuilding everything.
  • CSS color-mix does not survive the video rendering: the pill’s colours are computed by the script.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.6 KB; the libraries: GSAP 28 KB.

Testing

Tested on 25 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations