Skip to content
animorio
IT
Back to the library

Typeface-shifting word

Text, HoverGSAPMediumCompressed weight: Demo 5.0 KBGSAP 28 KBFreeDownload the zip

A hover effect on a word, in the minimal style: every letter is a small window with two typefaces in it, a serif and a sans. Where the pointer touches it, the serif letter rolls up and out and the same letter without serifs rises from below, in orange, one pixel too far and back; the neighbours slide over a hair because the two shapes are not the same width. When the pointer moves on, a short mark on the baseline counts down a moment and the letter turns serif again: a quick pass leaves a trail of different letters that turn back in the order you touched them.

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>
<!--
  "Typeface-shifting word" 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 word that changes typeface where you touch it</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full.css">
  <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>
    <!-- the word: every letter is a small window with the serif letter and the sans letter stacked in it.
         Touched, the letter rolls up from one face to the other and rolls back a moment after the pointer leaves -->
    <!-- the script adds the thin baseline rule inside it; the short accent marks on the rule count down the moment each
         letter stays changed -->
    <h1 class="parola" data-word aria-label="Regalia"></h1>
    <p class="nota" data-note>Run the pointer over the letters</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.

14 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 “Typeface-shifting word” 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 a thin rule draws itself from the middle and the letters of ‘Regalia’ rise one after the other into their little windows, in a high-contrast black serif sitting on the baseline; the g hangs below it. When the pointer touches a letter, the serif rolls up and vanishes into the edge of its window and the same letter rises from below in an orange sans, a little heavier than it should be: it lands one pixel high, settles, and the weight goes back to its place. The window widens or narrows on a spring for the new shape, so the neighbouring letters slide over a hair. As long as the pointer stays on it the letter stays changed; when the pointer leaves, a short orange mark appears under it and shrinks to nothing, and then the letter rolls up again and turns back into the black serif, like a drum that never turns backwards. A quick pass over the whole word leaves a trail of orange sans letters with their marks, turning back in the order you touched them. A click or a tap sends the change from that point out to both sides, through the whole word. If nobody touches it, an invisible pointer passes over it now and then, once one way and once the other.

How it works

One window, two faces

Every letter is a cell holding a window with hidden overflow and two copies of the letter, one in Fraunces and one in Mona Sans, stacked. GSAP moves them only with yPercent: 0 is in view, -101 is gone out of the top, 101 waits underneath.

Widths in em

Once the fonts are in, the width of both shapes of each letter is measured and divided by the type size. The cell takes its width from a CSS variable in em, which GSAP animates on a short elastic: so a resize has nothing to measure again.

A drum that only turns up

On the way there the serif face leaves through the top and the sans rises from below; on the way back the sans leaves through the top and the serif rises from below. The letter never goes backwards: it looks like a drum always turning the same way.

One pixel and a little weight

The face that arrives stops 1.4 pixels high, worked out from the window’s height, and comes down with sine.inOut. The sans arrives 90 points heavier and lightens as it settles.

The mark that counts

While the pointer is on the letter the count is stopped. When it leaves, a timeline grows the mark with back.out, shrinks it linearly for the waiting time and then turns the letter back: that is why a trail turns back in the order it was made.

Values to change

NameFileDefaultWhat it changes
WORDscript.jsRegaliaThe word.
HOLDscript.js0.9How many seconds a letter stays changed after the pointer has left it.
ROLLscript.js0.42How long the roll from one shape to the other takes, in seconds.
SERIF_WEIGHTscript.js380The weight of the serif.
SANS_WEIGHTscript.js540The weight of the sans.
SANS_WIDTHscript.js86The width of the sans: 75 is condensed, 125 is wide.
WAVEscript.jstrueA click sends the change through the whole word.
SPEEDscript.js1The speed of the invisible pointer when nobody touches the word.

Try them in the Playground

When to use it

For the headline of a type foundry, a design studio, a magazine or a portfolio, where the word itself should show that type is something you can touch.

On phones

The same animation with adapted sizes: the word is as big as the box allows, in width and height, and the letters change under the finger sliding over them.

With reduced motion

The letters do not roll: the two shapes cross-fade into each other and the mark underneath fades instead of shrinking.

Pitfalls

  • Mona Sans and Fraunces do not put the baseline at the same spot in the same line: the sans has to be nudged a tiny amount, in em, so both shapes sit on the same rule.
  • The widths have to be read after document.fonts.load for both typefaces: read earlier they belong to the fallback font and the cells stay the wrong width.

Libraries

GSAP 3.15.0, Fraunces (font variabile) 5.3.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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