Skip to content
animorio
IT
Back to the library

Text mask hero

Text, ScrollGSAP, CSS onlyMediumCompressed weight: Demo 7.5 KBGSAP + ScrollTrigger 45 KBLenis 5.3 KBFreeDownload the zip

Scroll inside the preview

The opening of Prism, a made-up light lab: a huge word cut out of the dark page works as a window onto slowly moving light, blobs of amber, honey, ember and peach with fine lines and grain. As you scroll the word widens and grows heavier, then the camera dives into the stem of the I until the window is the whole page; last, the line and the pill arrive. Minimal style, on black with a single warm colour.

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>
<!--
  "Text mask hero" 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>Prism Light Lab</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/anybody@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- Prism, a made-up light lab, opens its site with one huge word cut out of the dark page: through the letters you
       see slow light moving. As you scroll the word widens and grows heavier, then the camera dives into the stem of the
       I until the window becomes the whole page and the light is all there is; last, the line underneath arrives. -->
  <section class="corsa" data-corsa>
    <div class="palco" data-palco>
      <div class="luce" data-luce aria-hidden="true">
        <div class="luce__dentro" data-luce-dentro>
          <span class="macchia macchia--a" data-macchia></span>
          <span class="macchia macchia--b" data-macchia></span>
          <span class="macchia macchia--c" data-macchia></span>
          <span class="macchia macchia--d" data-macchia></span>
          <span class="righe" data-righe></span>
        </div>
        <span class="grana"></span>
      </div>

      <svg class="velo" data-velo aria-hidden="true">
        <defs>
          <mask id="finestra" maskUnits="userSpaceOnUse" data-mask>
            <rect data-pieno fill="#fff"></rect>
            <g data-gruppo-m><text data-testo-m fill="#000" text-anchor="middle">PRISM</text></g>
          </mask>
        </defs>
        <rect class="velo__notte" data-notte mask="url(#finestra)"></rect>
        <g data-gruppo-c><text class="velo__bordo" data-testo-c text-anchor="middle">PRISM</text></g>
      </svg>

      <header class="testa" data-testa>
        <p class="marca">
          <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3.5 20.5 19h-17Z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M12 3.5v15.5" stroke="currentColor" stroke-width="1.5"/></svg>
          Prism
        </p>
        <p class="etichetta">Light Lab <span>Colour studies in light</span></p>
      </header>

      <p class="misura" data-misura aria-hidden="true"><span>Window</span> <b data-misura-valore>1.00</b><i>×</i></p>
      <p class="invito" data-invito>Scroll</p>

      <div class="sotto" data-sotto>
        <h1 class="sotto__titolo" data-sotto-titolo>We mix light the way painters mix colour.</h1>
        <a class="pillola" href="#" data-pillola><span class="pillola__fondo"></span><span class="pillola__testo">See the studies</span></a>
      </div>
    </div>
  </section>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/ScrollTrigger.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/lenis@1.3.26/dist/lenis.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.

30 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Text mask hero” 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

At the top the Prism mark and «Light Lab», bottom left the window size rolling. In the middle the word PRISM is a hole in the black page: through it you see the light, four warm blobs drifting on their own, fine lines sliding and a fine grain, and the light follows the pointer a little. As you scroll the word widens on the width axis and grows heavier, then the camera dives into the stem of the I: the word grows around a point that slides from its centre to the centre of the I, until the window is bigger than the screen and the light is the whole page. Then the line «We mix light the way painters mix colour.» rises and settles as it widens, and the pill arrives.

How it works

The window

The black is an SVG rect with a mask: white everywhere and black where the letters are, so the light underneath shows only through the word. A second, invisible copy of the word is the one we measure (a text inside a mask cannot be measured).

The word in the centre

text-anchor middle centres the advance widths, not the ink: P and M have different side bearings. A canvas measures the ink at the nearest font-stretch keywords and the shift is interpolated; the cap height measured on the font puts the letters halfway up.

Widening

Over the first stretch of the scroll the width goes from 70 to 135 and the weight from 520 to 860, on power2.inOut, and the word stays centred on its ink.

The dive

The group is scaled around a point that slides from the centre of the word to the centre of the I: translate to the stage centre, scale, translate minus the point. The scale grows as exp(log(max)·t³), slow at first then fast, like a camera pushing in; the maximum is worked out so the stem of the I covers the screen.

The light

Four blobs with a radial gradient drift on their own in sine.inOut, back and forth; the fine lines slide 32 pixels and start again; the grain is an feTurbulence in a data URL. The pointer moves the light with two quickTo.

Values to change

NameFileDefaultWhat it changes
WORDscript.jsPRISMThe word that becomes the window: the letter in the middle is the one the camera dives into.
WIDTH_FROMscript.js70The width (wdth axis) of the word at the top of the page; Anybody goes from 50 to 150.
WIDTH_TOscript.js135The width of the word once it has widened.
WEIGHT_FROMscript.js520The weight of the word at the top of the page.
WEIGHT_TOscript.js860The weight of the word once it has widened.
WIDEN_ENDscript.js0.22How much of the scroll the widening takes.
DIVE_STARTscript.js0.18Where in the scroll the dive into the letter starts.
DIVE_ENDscript.js0.78Where in the scroll the window has become the whole page.
HOLDscript.js3How many screens the stage holds still while you scroll.
DRIFTscript.js14How many seconds a blob of light takes to drift one way.
PARALLAXscript.js26How many pixels the light inside the letters follows the pointer.

Try them in the Playground

When to use it

For the opening of the site of a studio, a brand or a product with a short, strong name: the name is the first thing you see, and the scroll opens it onto what the brand does.

On phones

The word is sized on the width and the height of the stage (at most 86% of the width and half the height at its widest), the stage is 100lvh tall, the long label at the top goes away under 560 pixels. Scrolling with a finger does everything; the light does not follow the finger.

With reduced motion

The result is already in place: the light is the whole page, still, with the line and the pill fading in; no dive and no smooth scroll.

Pitfalls

  • A text inside a <mask> cannot be measured: getBBox and getExtentOfChar are asked of an invisible copy of the word, with the same transform.
  • The box of an SVG text includes the room for ascenders and descenders: to centre the capitals use their real height, measured on a canvas.
  • A thirty-fold scale on an SVG text is done on the group with an SVG transform, not a CSS transform: that way the point it grows around is in stage coordinates.
  • Outlining the letters with a stroke shows the overlaps in the variable font’s outlines (the leg of the R): no outline here.

Libraries

GSAP 3.15.0, ScrollTrigger 3.15.0, Lenis 1.3.26, Anybody (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.5 KB; the libraries: GSAP + ScrollTrigger 45 KB, Lenis 5.3 KB.

Testing

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