Skip to content
animorio
IT
Back to the library

Shifting stress

Text, HoverGSAPEasyCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

A minimal text animation: the same six words, read six ways. A sentence sits on warm white, all of it said softly, light, narrow and grey; a thin cobalt stroke, the stress mark of a dictionary, hops from word to word, and where it lands that word takes the stress: it grows heavy and wide on the two axes of the variable typeface, on a spring that passes the mark by a hair and settles. Underneath, a line says what it means now. Pick the word with the pointer or a finger.

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>
<!--
  "Shifting stress" 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 sentence that shifts its stress</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="scena" data-stage>
    <div class="palco" data-palco>
      <!-- one sentence on two lines: the script splits it into words, and the stressed one takes weight and width -->
      <p class="frase" data-sentence></p>
      <!-- the stress mark, a thin slanted stroke that hops from word to word -->
      <span class="segno" data-mark aria-hidden="true"><span class="segno-tratto" data-mark-stroke></span></span>
      <!-- what the sentence means with the stress where it is now -->
      <p class="glossa" data-gloss aria-live="polite"></p>
    </div>
    <p class="nota" data-note>Hover a word to move the stress</p>
  </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.

16 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 “Shifting stress” 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 empty warm white the words of a sentence rise into place one after another, on two lines: ‘I never said / you were wrong.’. All of them are said softly: light, narrow and grey. From above a thin cobalt stroke drops in, the mark that dictionaries put before the stressed syllable, and comes to rest before the first word, squashing a little and springing back. At that instant the word takes the stress: on the two axes of the variable typeface it grows heavy and wide, passes the mark by a hair and settles, and turns from grey to black; the others make room for it and the ones next to it go lighter for an instant, as if from the knock. Under the sentence a small line says what it means now: ‘Someone else said it.’. After two seconds the mark crouches, hops in an arc onto the next word leaning into the flight, and the stress goes with it: ‘Not once, not ever.’, ‘I only thought it.’, ‘I meant someone else.’, ‘You still are.’, ‘I said you were late.’. Then it goes back to the first word and starts again. With the pointer over a word the mark hops there and the sentence stays on that reading; tapping a word squeezes it a little and picks it. A click on the empty page starts everything again.

How it works

Two axes per word

Every word has one number, its stress, from 0 to 1. Every frame it becomes font-variation-settings with wght from 300 to 820 and wdth from 86 to 118, and a colour from grey to black mixed by hand. The line is centred: when a word widens, the others move by themselves to make room.

A spring for the stress

Each word’s stress chases its target on a spring (stiffness 240, damping from 31 to 11 depending on BOUNCE): below critical damping it passes the mark by a hair and comes back. When the mark lands, the nearby words get a push backwards that fades with distance.

The hop reads both words again

The mark flies on a number p from 0 to 1 animated by GSAP; the start and the end are read again every frame with getBoundingClientRect, because the words move while their weight changes. The arc is a sine as high as the distance, the lean follows the direction.

Crouch, land

Before the hop the stroke squashes to 0.78 and stretches to 1.12; on arrival it squashes to 0.66, widening, and comes back with elastic.out. The word that receives it drops a pixel and a half and comes back up.

The walk and the hand

The walk on its own is a gsap.delayedCall that moves on to the next word; with the pointer over a word the walk stops, and it starts again a second and a half after the pointer has left the sentence. On a phone you pick by tapping.

Values to change

NameFileDefaultWhat it changes
SENTENCEscript.jsI never said / you were wrong.The sentence: the slash breaks the line.
LIGHT_WEIGHTscript.js300The weight of the words said softly.
STRESS_WEIGHTscript.js820The weight of the stressed word.
LIGHT_WIDTHscript.js86The width of the soft words, from 75 to 125.
STRESS_WIDTHscript.js118The width of the stressed word, from 75 to 125.
BOUNCEscript.js0.5How far the stress passes the mark before it settles.
HOLDscript.js2.1How many seconds the stress stays on each word.
SPEEDscript.js12 = twice as fast, 0.5 = half as fast.
LOOPscript.jstrueWalk through the sentence again and again.

Try them in the Playground

When to use it

For the page of an acting or diction school, a podcast, a dubbing or copywriting studio, for a quote in a blog or a portfolio that should make you think about how things are said.

On phones

The same animation with adapted sizes: the sentence is as big as the box allows, in width and height, and you pick the word with a finger.

With reduced motion

No hops and no springs: the mark fades out and back in on the new word, the word takes the stress already in place and the line underneath changes in a fade.

Pitfalls

  • The words change width while the mark is flying: the start and the end must be read again every frame, not only when the hop begins.
  • On the spring the weight can drop below 100 or rise above 900 in the overshoot: it has to be kept within the limits of the typeface.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 1 November 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