Skip to content
animorio
IT
Back to the library

Self-sorting headline

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 5.1 KBGSAP 28 KBFreeDownload the zip

The opening of a made-up app that plans your week, on near black and in the style of product pieces: the headline arrives with its words in the wrong order, thin and grey, and sorts itself out, two words at a time. The right word hops over the row in a small arc, the other one dips and gives way; every word that finds its place gains weight and light. The last one turns lavender and pink, then the subtitle and the two buttons come in.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Self-sorting 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 whose words sort themselves into order</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 planning app: the headline arrives with its words in the wrong order and sorts itself,
         two words at a time, then the subtitle and the two buttons come in -->
    <section class="hero" aria-label="Plotwell">
      <a class="pill" href="#" data-pill>
        <span class="pill__tag">New</span>
        <span class="pill__text">Auto-scheduling is here</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 aria-label="Your week, planned in seconds."></h1>

      <p class="sub" data-sub>Plotwell reads your tasks, your meetings and your energy, and lays out the week before you have finished your coffee.</p>

      <div class="actions" data-actions>
        <a class="btn btn--primary" href="#" data-btn>
          <span class="btn__shine" aria-hidden="true"></span>
          <span class="btn__label">Plan my week</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.

20 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 “Self-sorting 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 near black background the “New · Auto-scheduling is here” pill appears at the top. Then the headline arrives, but wrong: “seconds. planned Your in week,”, thin grey words rising out of a blur. The headline sorts itself from the left: the word that belongs first jumps over the row in a small arc and grows a touch, the one sitting in its place dips slightly and slides away, and all the others move together without jumps, because the row reflows at every swap. Each word that reaches its place gains weight, from thin to full, turns white and settles one pixel past; underneath it leaves a thin trace that widens and fades. Three swaps are enough for “Your week, planned in seconds.”; the last word takes a lavender and pink gradient that slides in from the left. Then the subtitle and the two buttons rise, and a sheen crosses the first one. On hover every word gains a little more weight and lifts two pixels; the buttons squash when pressed. After a pause everything fades and starts again.

How it works

Hand-made FLIP

At every swap the script measures all the words, changes the order in the DOM and measures again: each word starts where it was (x and y equal to the difference) and goes to zero with back.out. Words that wrap to the next line or come back up move smoothly too, with no position computed by hand.

A selection sort

The headline sorts itself like a selection sort: for each slot, from the left, the right word swaps with the one sitting there. With the starting order 4,2,0,3,1 it takes three swaps; words already in place only settle.

Two elements per word

The outer span is moved by the FLIP, the inner one does the arc (a quarter em up and back with back.out), the weight with Mona Sans’s wght axis, the colour and the one-pixel settle. That way the transforms do not erase each other.

The last word’s colour

The last word has a 220% wide gradient clipped to the text: when it reaches its place the text colour turns transparent and the background position slides from 0 to 100%, so the white gives way to lavender and pink.

Values to change

NameFileDefaultWhat it changes
HEADLINEscript.js'Your week, planned in seconds.'The headline in the right order; the last word gets the colour.
SCRAMBLEscript.js'4,2,0,3,1'The wrong order it arrives in: the positions of the words, counted from zero.
SWAP_TIMEscript.js0.62The seconds of each swap between two words.
SWAP_GAPscript.js0.18The pause between one swap and the next.
LIFTscript.js0.26How far the word passing over lifts, in em.
WEIGHT_OFFscript.js380The weight of the words out of place.
WEIGHT_ONscript.js680The weight of the words in place.
HOLDscript.js3.6The seconds the headline stays sorted before starting again.

Try them in the Playground

When to use it

For the opening of an app or a product that brings order: a planner, a task manager, an assistant that sorts mail or files. The headline tells on its own what the product does.

On phones

The same animation: the headline runs over two or three lines and swaps also cross from one line to another, with the same arc; the subtitle and buttons stay inside the box.

With reduced motion

No swaps or arcs: the headline appears already in order, at full weight with the last word coloured, and everything fades in.

Pitfalls

  • Before measuring, the offsets of the previous FLIP must be reset: measuring a word still in flight starts it from the wrong place.
  • The arc and the settle live on the inner span: put them on the same element as the FLIP and GSAP would overwrite the y and the word would jump.
  • With background-clip: text the coloured word needs a transparent text colour, but only once the gradient is in place, otherwise it vanishes for a moment.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 26 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