
The layered button
Buttons, Hover, Physics
The volume control of a music player, on very light grey, in the style of one-gesture micro-interactions: you drag the handle and the filled part follows a beat late, like a soft trail that stretches and pulls back. The volume number rolls, the speaker loses and gains its waves, past the ends the track stretches a few pixels on an elastic, and at zero the mute line draws itself.
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>
<!--
"Trailing volume slider" 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 volume slider that leaves a trail</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" data-stage>
<!-- the volume of a speaker in a player: drag the handle and the filled part follows a beat late,
like a soft trail; past the ends the track stretches a few pixels and springs back -->
<section class="card" data-card aria-label="Volume">
<header class="card__head">
<div class="cover" aria-hidden="true"><span></span></div>
<div class="track-info">
<p class="track-info__title">Low Tide</p>
<p class="track-info__meta">Aurel Venn · Living room</p>
</div>
<p class="value" aria-hidden="true">
<span class="value__digits" data-digits></span>
</p>
</header>
<div class="row">
<button class="speaker" type="button" data-speaker aria-label="Mute">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path class="speaker__body" d="M4 9.5h3.2L11.5 6v12l-4.3-3.5H4z"></path>
<path class="speaker__wave" data-wave="0" d="M14.4 10.2a2.6 2.6 0 0 1 0 3.6"></path>
<path class="speaker__wave" data-wave="1" d="M16.4 8.3a5.3 5.3 0 0 1 0 7.4"></path>
<path class="speaker__wave" data-wave="2" d="M18.4 6.4a8 8 0 0 1 0 11.2"></path>
<path class="speaker__slash" data-slash d="M15 9.5l5 5M20 9.5l-5 5" pathLength="1"></path>
</svg>
</button>
<div class="slider" data-slider role="slider" tabindex="0" aria-label="Volume" aria-valuemin="0" aria-valuemax="100" aria-valuenow="60">
<div class="rail" data-rail>
<div class="rail__track" data-track>
<div class="rail__trail" data-trail></div>
<div class="rail__fill" data-fill></div>
</div>
<div class="handle" data-handle><span class="handle__dot" data-knob></span></div>
</div>
<div class="ticks" data-ticks aria-hidden="true"></div>
</div>
</div>
</section>
<svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></path></svg>
</main>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<script src="script.js"></script>
</body>
</html>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.
17 values to change
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 “Trailing volume slider” from Animorio and fit it into my siteThe handle has its value v, the trail a value lag that chases it on every frame of the GSAP ticker by 1 minus e to the minus dt times TRAIL. The black part reaches the smaller of the two, the light trail the larger: so going forward the trail is ahead of the black, going back it stays past the handle.
Past the end the extra is squashed with a hyperbolic tangent, STRETCH times tanh of the excess over four STRETCH: you pull a lot and the track stretches a few pixels. The stretch is a scaleX anchored on the opposite side; once let go, it goes back to zero with elastic.out.
The number is three columns with the digits 0 to 9 stacked: GSAP moves each column to yPercent minus ten times the digit. Hundreds and tens have zero width when not needed and open with a transition, so the number does not jump sideways.
Dragging uses pointer events with setPointerCapture and the track has touch-action: none, so on a phone the finger drags it instead of scrolling the page. The arrows move by STEP, Page Up and Down by ten, Home and End go to the ends; the speaker is a real button.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | 60 | The starting volume, from 0 to 100. |
TRAIL | script.js | 7 | How fast the trail catches the handle: higher means a shorter trail. |
STRETCH | script.js | 9 | How many pixels at most the track stretches when pulled past the ends. |
HOLD_GROW | script.js | 1.5 | How much the track thickens while held. |
ACCENT | script.js | #5b5bf6 | The colour of the trail and the lit ticks. |
FILL | script.js | #18181b | The colour of the filled part. |
STEP | script.js | 5 | How much the arrow keys move the volume. |
In the player of a music or podcast app, in the control of a home speaker, in a video call app or an audio panel: anywhere a volume is set and the gesture should be felt, not just its number seen.
The card takes the width of the box minus the margins and the track remeasures to its real width, even when the phone turns. With a finger the handle drags as with the mouse, without scrolling the page.
No trail, elastic or squash: the filled part follows the handle at once, the digits change without rolling, and the autopilot shows the values one after another.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.7 KB; the libraries: GSAP 28 KB.
Tested on 26 October 2026
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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
You asked for
We made it for you: it’s in the library, with the preview, the Playground and the code to copy.
An animation you can’t find, or a site to take apart in the journal: tell us which. We pick the next ones from here.
With your account’s email and password.
or with your email
You’re signed in as .
With your account, you can download the zip of every animation and every pack, for free.