Skip to content
animorio
IT
All components

Listen to article button

Buttons, Hover, TextGSAP, CSS onlyAdvancedCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

The Listen to this article button of an invented magazine, an ivory pill on warm paper. Pressed, it becomes a small player: play splits and turns into pause, the voice waveform moves with the syllables of the words, the time runs on from 4:12 of 9:30 and the speed rolls from 1x to 1.25x. Under the pill the sentence being read comes in like a caption, with a marker on the word being said.

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>
<!--
  "Listen to article button" 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 Listen to this article button with captions that follow the voice</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the Listen to this article button of an invented magazine, Halyard Review, on warm paper in soft light.
         Pressed, the pill opens into a small player: play turns into pause, a waveform moves with the voice, the time
         runs on and the speed rolls from 1x to 1.25x. Under the pill, outside it, the sentence being read appears like
         a caption, with a marker on the word the voice is saying -->
    <div class="la" data-wrap>
      <div class="la__pill" data-pill>
        <span class="la__skin" aria-hidden="true">
          <span class="la__fill"></span>
          <span class="la__light" data-light></span>
          <span class="la__track"><span class="la__done" data-done></span></span>
          <span class="la__edge"></span>
        </span>

        <button class="la__disc" type="button" data-disc aria-label="Pause" tabindex="-1">
          <span class="la__disc-face">
            <svg class="la__icon" viewBox="0 0 24 24" aria-hidden="true">
              <polygon data-half="a" points="8.5,6 12.4,8.5 12.4,15.5 8.5,18"/>
              <polygon data-half="b" points="12.4,8.5 18,12 18,12 12.4,15.5"/>
            </svg>
          </span>
        </button>

        <span class="la__rest" data-rest aria-hidden="true">
          <span class="la__title" data-r>Listen to this article</span>
          <span class="la__sub" data-r>
            <svg class="la__phones" viewBox="0 0 16 16"><path d="M2.6 10.4V8.2a5.4 5.4 0 0 1 10.8 0v2.2"/><rect x="2" y="9.4" width="2.8" height="4.4" rx="1.2"/><rect x="11.2" y="9.4" width="2.8" height="4.4" rx="1.2"/></svg>
            <span>9 min 30 · Read by Ines Marlow</span>
          </span>
        </span>

        <button class="la__open" type="button" data-open aria-label="Listen to this article, 9 minutes 30" data-autoclic></button>

        <span class="la__ctrl" data-ctrl>
          <span class="la__wave" data-wave aria-hidden="true"></span>
          <span class="la__time" aria-label="Time">
            <span class="la__now" data-now></span>
            <span class="la__total" data-total></span>
          </span>
          <button class="la__speed" type="button" data-speed aria-label="Playback speed 1x">
            <span class="la__speed-face">
              <span class="la__speed-win" data-speed-win><span class="la__speed-col" data-speed-col></span></span>
            </span>
          </button>
          <button class="la__close" type="button" data-close aria-label="Close the player">
            <span class="la__close-face">
              <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 4.5l7 7M11.5 4.5l-7 7"/></svg>
            </span>
          </button>
        </span>
      </div>

      <div class="la__cap" data-cap aria-hidden="true">
        <div class="la__cap-in" data-cap-in>
          <p class="la__kicker" data-kicker>Now reading · Halyard Review</p>
          <p class="la__line" data-line><span class="la__mark" data-mark></span></p>
        </div>
      </div>

      <div class="la__script" data-script hidden>
        <p>Every harbour keeps two clocks, one for the ships and one for the tide.</p>
        <p>The second never hurries, and the town slowly learns to wait for it.</p>
        <p>By noon the water had come back, quietly, as if it had never left.</p>
      </div>
    </div>

    <svg class="la__pointer" data-pointer viewBox="0 0 28 28" aria-hidden="true">
      <path d="M6.2 3.6l15 10.6c.8.6.5 1.8-.5 1.9l-6 .7 3.4 6.4c.3.6.1 1.3-.5 1.6l-1.7.9c-.6.3-1.3.1-1.6-.5l-3.4-6.5-4.3 4.2c-.7.7-1.9.2-1.9-.8V4.4c0-.9 1-1.4 1.6-.8z"/>
    </svg>
    <p class="sr" aria-live="polite" data-live></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.

25 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 “Listen to article button” 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 warm paper, with a soft light from the top left and a fine grain, there is an ivory pill whose edges catch the light: on the left an ink disc with play, beside it Listen to this article and, in grey, drawn headphones, 9 min 30 and the name of the voice, Read by Ines Marlow. Pressed, the pill squeezes and springs back, the two lines rise and fade, play splits into two halves that become the two bars of pause and the pill stretches with a small bounce into a player: the voice waveform, the time 4:12 / 9:30, the speed button 1x and an X. Meanwhile the caption opens under the pill: Now reading · Halyard Review and the sentence of the article, in a soft serif. The waveform scrolls from right to left and answers the voice: every word has its syllables, the first one louder, and at commas and full stops the voice takes a breath and the bars drop; the last three, the ones of now, are vermilion. A peach marker slides from word to word with the voice, the word being said hops by one pixel, the words already read turn to ink and the others stay pale; at the full stop the sentence lifts away and the next one rises from below. The time runs on second by second with rolling digits and a vermilion hairline grows along the bottom of the pill. The speed button rolls 1x up and brings in 1.25x, then 1.5x and 2x, and the voice reads faster. Pause lowers the bars from the oldest to the newest to a third of their height, where they stay still and pale like a paused waveform, and dims the time and the marker; play lifts them back the other way and the marker lights up again with a small bounce. The X folds the player and the caption away and the pill is Listen to this article again. A drawn pointer goes round by itself until you touch something.

How it works

A fake but believable voice

The sentences live in the HTML. Every word becomes a length (0.16 seconds plus 0.072 per letter), a number of syllables (the vowel groups) and a breath after it: 0.3 at commas, 0.62 at full stops. Then everything is multiplied by one number, so the voice reads WORDS_PER_SEC words a second on average. The level at any instant is half a sine for each syllable, the first one louder, short words softer.

The scrolling waveform

Thirty times a second the level, with a quick attack and a slow release, enters a row of values on the right and the oldest one leaves on the left; every bar writes its height in pixels (not scaleY, which would squash the round ends). On a phone the bars that do not fit hide from the left, under the mask’s fade.

A pause that settles

One number, settle, goes from 1 to 0: every bar has its own threshold, g = settle × 1.6 − 0.6 × (1 − position), so the oldest bars drop first and the newest last, down to a third of their height; on play it happens the other way round.

The marker and the caption

Every word is a span; the peach rectangle behind the text takes offsetLeft, offsetTop and the size of the word being said and slides onto it with power3.out in a time that shortens with the speed (from 0.26 to 0.1 seconds). At the end of a sentence the words lift with an 8 millisecond stagger and the next sentence rises from below; the caption opens by animating its measured height, so the pill moves up by itself.

Play and pause that split, and the rollers

Play is drawn as two four-point shapes that together make the triangle; GSAP moves the points to the two bars of pause. The time has one window per digit and the speed a column of values (with the first one repeated at the end, so after 2x it goes back to 1x always rolling up).

Values to change

NameFileDefaultWhat it changes
STARTscript.js4:12Where the reading is when the player first opens.
LENGTHscript.js9:30How long the whole article lasts.
SPEEDSscript.js[1, 1.25, 1.5, 2]The speeds of the roller, one per tap.
WORDS_PER_SECscript.js2.6How many words a second the voice reads at 1x.
BARSscript.js26The most bars the waveform has (on a phone the ones that do not fit hide).
LIVELYscript.js1How strongly the bars follow the voice: 0.3 calm, 1.6 loud.
SQUEEZEscript.js0.95How much the pill squeezes when pressed (1 = not at all).
SPRINGscript.js1How springy the moves are: 0.4 calm, 2 very bouncy.
AUTOscript.jstrueThe drawn pointer goes round by itself until someone touches it.

Try them in the Playground

When to use it

At the top or the bottom of the articles of a blog, a magazine or a newspaper you can listen to, in newsletters read aloud, in reading apps, on sites with text to speech and wherever captions help people who listen and read at the same time.

On phones

The same animations: the pill and the caption take almost the whole width, the waveform keeps only the bars that fit and the caption is sized on the screen height too; a finger presses like the mouse and the player’s buttons are easy to tap.

With reduced motion

No squeezes, stretches, scrolling waves or pointer: the pill changes face with a fade, the bars stay still at their height, the marker jumps from word to word, the sentences change with a fade and the time still runs.

Pitfalls

  • The marker slid in 0.3 seconds and at 1.25x lagged halfway between two words: its time now depends on the speed of the voice.
  • On pause every bar dropped to three pixels and the waveform became a row of dots: now they stay still at a third of their shape, pale.
  • With scaleY the two-pixel bars squashed their round ends too and at rest looked like dashes: every bar writes its height in pixels.
  • At 2x the breath of the full stop lasted less than the sentence’s exit, and the marker jumped to the first word of the old sentence: the caption remembers which sentence it shows and the marker waits for the right one.
  • The speed roller from 2x to 1x went back down the whole column: there is a copy of 1x at the end, the column always rolls up and at the end jumps back unseen.
  • On a phone twenty-six bars sat less than a pixel apart and made a smudge: the ones without at least five and a half pixels hide, from the left.
  • The closed pill has no width of its own (everything inside is absolute): the resting and the open widths are measured for real, and again on resize and when the fonts arrive.

Libraries

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

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

Testing

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