Skip to content
animorio
IT
All components

Video subtitles

Players, Text, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.9 KBGSAP 28 KBFreeDownload the zip

The subtitles of a video player on black, for «Quiet Harbour», a made-up series. Each line arrives faint and its words settle out of a thin blur as the voice says them; the next line pushes the first away with a small slide. The CC button opens a glass menu: the language (English, Italiano, Español) recomposes the line in the new language with the words already said in place, and the size S, M, L slides the knob and resizes the caption pill on a spring; the CC underline lights up while subtitles are on.

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>
<!--
  "Video subtitles" 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>Video subtitles</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/geist@5.3.0/index.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>
  <main class="stage">
    <!-- the subtitles of a video player: each line arrives dim and its words settle out of a faint blur as the voice
         says them; the CC menu changes the language (the line recomposes in the new one) and the text size (the
         caption pill resizes on a spring); the CC underline lights up while subtitles are on -->
    <section class="player" data-player aria-label="Video player">
      <div class="frame" aria-hidden="true">
        <div class="frame__sky"></div>
        <div class="frame__sun" data-sun></div>
        <div class="frame__sea"></div>
        <div class="frame__line"></div>
        <div class="frame__grain"></div>
      </div>

      <header class="top" aria-hidden="true">
        <span class="top__title">Quiet Harbour</span>
        <span class="top__ep">Episode 3 · The Night Ferry</span>
      </header>

      <div class="caps" data-caps>
        <p class="cap" data-cap aria-live="polite"></p>
      </div>

      <div class="menu" data-menu role="dialog" aria-label="Subtitles" hidden>
        <p class="menu__head">Subtitles</p>
        <div class="menu__list" role="radiogroup" aria-label="Language" data-langs>
          <button type="button" role="radio" aria-checked="false" data-lang="off"><span>Off</span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.4l3 3 6-6.6" pathLength="1"/></svg></button>
          <button type="button" role="radio" aria-checked="true" data-lang="en"><span>English</span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.4l3 3 6-6.6" pathLength="1"/></svg></button>
          <button type="button" role="radio" aria-checked="false" data-lang="it"><span>Italiano</span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.4l3 3 6-6.6" pathLength="1"/></svg></button>
          <button type="button" role="radio" aria-checked="false" data-lang="es"><span>Español</span><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.4l3 3 6-6.6" pathLength="1"/></svg></button>
        </div>
        <div class="menu__size">
          <span class="menu__label">Size</span>
          <div class="sizes" role="radiogroup" aria-label="Text size" data-sizes>
            <span class="sizes__knob" data-knob aria-hidden="true"></span>
            <button type="button" role="radio" aria-checked="false" data-size="s">S</button>
            <button type="button" role="radio" aria-checked="true" data-size="m">M</button>
            <button type="button" role="radio" aria-checked="false" data-size="l">L</button>
          </div>
        </div>
      </div>

      <div class="bar">
        <button type="button" class="icon" data-play aria-label="Pause">
          <svg viewBox="0 0 20 20" aria-hidden="true"><g data-ico-pause><rect x="5" y="4" width="3.4" height="12" rx="1.2"/><rect x="11.6" y="4" width="3.4" height="12" rx="1.2"/></g><path data-ico-play d="M6 4.2v11.6a.8.8 0 0 0 1.2.7l9.4-5.8a.8.8 0 0 0 0-1.4L7.2 3.5A.8.8 0 0 0 6 4.2z"/></svg>
        </button>
        <span class="time" data-time aria-hidden="true">12:04</span>
        <div class="track" aria-hidden="true"><span class="track__done" data-done></span><span class="track__head" data-head></span></div>
        <span class="time time--end" aria-hidden="true">41:30</span>
        <button type="button" class="cc" data-cc aria-label="Subtitles" aria-expanded="false" aria-pressed="true">
          <span class="cc__box">CC</span>
          <span class="cc__line" data-cc-line aria-hidden="true"></span>
        </button>
      </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.

31 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 “Video subtitles” 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

A black video player with a frame made of shapes and light: a harbour at sunset, the low pale-green sun slowly sinking to the sea line, grain on top. At the top «Quiet Harbour» and «Episode 3 · The Night Ferry». At the bottom the bar: Pause, the time running from 12:04, the mint timeline and the CC button with its underline lit. Above the bar the subtitles of a dialogue between Mara and Jonah: each line comes in faint, the words light up one at a time with the voice, settling out of a small blur, and the speaker’s name is in the accent colour; the finished line rises and vanishes and the next one arrives. CC opens a glass menu with Off, English, Italiano and Español, each with a check that draws itself, and below it the size S, M, L. Changing language blurs the line’s words away and the new ones recompose, already lit as far as the voice had got; changing size slides the knob and the caption pill grows or shrinks on a spring. Off turns off the underline and the subtitles. Every button gives under the press and comes back with a bounce. When nobody touches it, the demo changes language and size by itself.

How it works

A voice clock

A number rises with the GSAP ticker (the real time between frames, at most 100 ms). Each line has a start and a speaking time worked out from the English words, WORD_PACE seconds each: so every language speaks in the same beats, and word k of n lights up at k/(n − 1) of the time.

The word that settles

The words are separate spans, all at DIM opacity. When the voice reaches a word, a fromTo takes it from blur(BLUR px) and 0.12 em lower to sharp and in place in 0.42 s with power2.out.

Switching language halfway

It takes the share of words already said, the old ones blur away 0.012 s apart and the line is rebuilt in the new language with the same share lit, the words coming in staggered out of the blur.

The size on a spring

The selector knob takes the x, width and height of the chosen button with back.out; the caption pill goes to its new font-size in em with elastic.out(1, SPRING), and the background follows by itself because it is the same box.

Values to change

NameFileDefaultWhat it changes
WORD_PACEscript.js0.3Seconds between two spoken words.
HOLDscript.js1.1Seconds a finished line stays before the next one.
DIMscript.js0.4Opacity of the words not said yet.
BLURscript.js5Pixels of blur each word settles out of.
SIZE_Sscript.js0.95Subtitle size S, in em.
SIZE_Mscript.js1.25Subtitle size M, in em.
SIZE_Lscript.js1.6Subtitle size L, in em.
SPRINGscript.js0.55How much the pill bounces when it changes size (lower, more bounce).
IDLEscript.js7Seconds without touches before the demo goes back to changing language and size by itself.

Try them in the Playground

When to use it

In any video player on a site: streaming, courses, interviews, trailers, product videos; wherever viewers may have the sound off or speak another language, and subtitles must be readable, in the right language and at the right size.

On phones

The player is taller, the menu a little narrower and lower; sizes are in em tied to width and height, so player, subtitles and menu fit the box. A tap is the click.

With reduced motion

No movement or blur: lines fade in, words light up without settling, the language change cross-fades, the size changes at once and the menu fades in.

Pitfalls

  • Word timing must come from a single language: with each language’s own timing, switching halfway would make the voice jump forwards or back.
  • Animate font-size on the pill, not on each word: background, border and wrapping follow by themselves.
  • Measure the size knob with the menu open: closed it is display none and offsetLeft is zero.

Libraries

GSAP 3.15.0, Geist (font variabile) 5.3.0, Geist Mono (font variabile) 5.3.0.

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

Testing

Tested on 27 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 components