Skip to content
animorio
IT
All components

Playback speed button

Buttons, Hover, TextGSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The playback speed button of an audiobook and podcast app’s player: a white “1×” pill with three orange bars moving like sound. Each tap steps it to 1.25×, 1.5×, 1.75×, 2× and back to 1×: the digits roll vertically, the pill widens or narrows on a spring and the × stays still, while the bars speed up and draw closer. Held down, the pill stretches into a fine slider from 0.5× to 3× with ticks and a two-decimal value following the finger; let go, it becomes a pill again with the chosen value. Minimal style.

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>
<!--
  "Playback speed 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>Playback speed button</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="stage">
    <!-- the playback speed button of a audiobook player: tap to step 1x, 1.25x, 1.5x, 1.75x, 2x and back;
         press and hold to stretch it into a fine slider from 0.5x to 3x, let go and it becomes a pill again -->
    <div class="frame" data-frame>
      <div class="press" data-press>
        <button class="pill" type="button" data-pill aria-label="Playback speed, 1 times" aria-describedby="speed-hint">
          <span class="pill__shine" aria-hidden="true"></span>
          <span class="bars" data-bars aria-hidden="true"><i></i><i></i><i></i></span>
          <span class="num" data-num aria-hidden="true">
            <span class="slot slot--int" data-slot="int"><span class="col" data-col></span></span>
            <span class="slot slot--dot" data-slot="dot"><span class="dot">.</span></span>
            <span class="slot slot--d1" data-slot="d1"><span class="col" data-col></span></span>
            <span class="slot slot--d2" data-slot="d2"><span class="col" data-col></span></span>
          </span>
          <svg class="times" viewBox="0 0 10 10" aria-hidden="true"><path d="M2.2 2.2l5.6 5.6M7.8 2.2l-5.6 5.6"></path></svg>
          <span class="track" data-track aria-hidden="true">
            <span class="track__rail"><span class="track__fill" data-fill></span></span>
            <span class="track__ticks" data-ticks></span>
            <span class="track__thumb" data-thumb></span>
          </span>
        </button>
      </div>
    </div>
    <p class="sr" id="speed-hint">Tap to change speed, hold to choose it precisely, or use the arrow keys.</p>
    <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.

18 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 “Playback speed 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 a white background, in the middle, a white pill 60 pixels tall with a gradient a touch warmer at the bottom, a thread of light along its top edge and three soft shadows: on the left three orange bars rising and falling like a small sound, then “1” and a drawn grey ×. Hovered, the pill swells a breath; pressed, it squashes, the shadow tightens under it, and released it springs back. Each tap steps the speed to 1.25, 1.5, 1.75, 2 and back to 1: every digit rolls vertically in its faded window and lands with a settle, the dot and the decimals come in or out by narrowing their slot, so the pill widens or narrows on a spring while the × stays still beside the number. The bars follow the speed: quicker and closer at 2×, slow and wide at 1×, and they jump a little at every change. Held for a moment, the pill stretches on a spring into a fine slider: the number goes to two decimals (1.75), the rail appears, eleven ticks rise one after the other with the labels 0.5, 1, 2, 3, the orange fill and the handle, which follows the finger in steps of 0.05 while the digits roll fast; crossing a tick, the tick lights up orange and grows. Let go, the slider fades, the decimals that are not needed leave (1.35 stays 1.35, 2.00 goes back to 2) and the pill closes to its size. With the keyboard Enter and Space change speed, the arrows adjust it by 0.05.

How it works

Four slots for one number

The number is made of four fixed slots: the unit, the dot, the tenths and the hundredths. The three digit slots hold a 0 to 9 column moving vertically by 30 pixels a digit; a faded mask above and below lets them come and go softly.

Width that follows the digits

When a decimal is needed or no longer needed, GSAP brings its slot width to one digit (with back.out) or to zero. The pill has automatic width, so it widens and narrows by itself on that spring, and the × stays attached to the number.

Press and hold

On press a 0.38 second delayedCall starts: if the finger lifts first it is a tap and the speed steps to the next one, otherwise the pill fixes its current width and GSAP takes it to the slider’s. With the pointer captured, every move becomes a value between 0.5 and 3 rounded to 0.05.

Closing to the right size

On release the width the pill will have with the short number is worked out (padding, bars, visible slots, ×) and reached on a spring; at the end the width goes back to automatic.

Bars on the ticker

On the GSAP ticker a phase advances at the shown speed, which chases the chosen one through a soft filter: each bar gets its height from two offset sines, and the space between the bars tightens from 3.6 to 1.1 pixels on the way to 3×.

Values to change

NameFileDefaultWhat it changes
STEPSscript.js1, 1.25, 1.5, 1.75, 2The speeds a tap steps through, in order.
MIN_SPEEDscript.js0.5The lowest speed on the fine slider.
MAX_SPEEDscript.js3The highest speed on the fine slider.
HOLD_TIMEscript.js0.38How long to hold before the pill becomes a slider.
ROLL_TIMEscript.js0.55How long the digits take to roll.
SPRINGscript.js1.6How far the pill overshoots and comes back when its width changes.
WAVE_RATEscript.js1.4How quickly the bars move at 1×.

Try them in the Playground

When to use it

In the player of a podcast or audiobook app, in the video player of an online course, in the voice messages of a chat, in the read-aloud article of a blog.

On phones

The pill stays 60 pixels tall and the open slider takes the screen width minus a margin, so it always fits the preview box; press and hold works with a finger and the page does not scroll while dragging.

With reduced motion

The digits change at once without rolling, the pill changes width without a spring, the slider fades in, the bars stand still and the self-running preview does not start.

Pitfalls

  • With automatic width the pill cannot be animated to the slider: first its current width is fixed, then animated, and at the end removed.
  • The width measured while the pill is squashed is smaller: it is divided by the pressed wrapper’s scale.
  • The digits of a slot coming back start below the window, otherwise the decimal appears already still instead of rolling.
  • Without touch-action none the finger dragging the slider scrolls the page.
  • Mona Sans’s tabular figures have a dotted zero and look like a mono face: the slots take the widest digit’s width and the normal figures sit centred.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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