Skip to content
animorio
IT
All components

Glass capsule volume slider

Sliders, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 7.2 KBGSAP 28 KBFreeDownload the zip

The volume control of an invented speaker app, on black, in a minimal premium control-centre style: a vertical capsule of dark glass where the filled part rises from below and its surface is a live sound wave, wider and faster the higher the volume. Drag it up and down: the capsule narrows under the finger, the grip squeezes, a trail stays behind and past the ends it stretches on an elastic; at zero the wave lies flat and the speaker mutes with a bounce, past 90% the top warms to orange.

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>
<!--
  "Glass capsule 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 glass capsule volume slider with a rising wave</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/inter@5.2.5/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage" data-stage>
    <!-- the volume capsule of an invented speaker app: the filled part rises from the bottom and its surface is a
         live sound wave, wider and faster the louder it gets; it lies flat at zero and warms up past 90% -->
    <section class="unit" data-card aria-label="Living room speaker">
      <div class="capsule" data-capsule role="slider" tabindex="0" aria-label="Volume" aria-orientation="vertical"
           aria-valuemin="0" aria-valuemax="100" aria-valuenow="58" aria-valuetext="58%">
        <div class="capsule__glass" data-glass>
          <svg class="capsule__svg" data-svg aria-hidden="true">
            <defs>
              <linearGradient id="vol-fill" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0" stop-color="var(--fill-top)"></stop>
                <stop offset="1" stop-color="var(--fill-low)"></stop>
              </linearGradient>
              <linearGradient id="vol-heat" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="0" y2="80" data-heat-grad>
                <stop offset="0" stop-color="var(--heat)" stop-opacity="1"></stop><stop offset="0.35" stop-color="var(--heat)" stop-opacity="0.55"></stop>
                <stop offset="1" stop-color="var(--heat)" stop-opacity="0"></stop>
              </linearGradient>
            </defs>
            <path class="capsule__trail" data-trail></path>
            <path class="capsule__fill" data-fill fill="url(#vol-fill)"></path>
            <path class="capsule__heat" data-heat fill="url(#vol-heat)"></path>
            <path class="capsule__crest" data-crest></path>
          </svg>
          <span class="capsule__sheen" aria-hidden="true"></span>
          <span class="capsule__grip" data-grip aria-hidden="true"></span>
          <span class="capsule__icon" data-icon aria-hidden="true">
            <svg viewBox="0 0 24 24">
              <path class="spk__body" d="M4 9.2h3.1L11.6 5v14l-4.5-4.2H4z"></path>
              <path class="spk__arc" data-arc d="M14.3 10.1a2.6 2.6 0 0 1 0 3.8"></path>
              <path class="spk__arc" data-arc d="M16.4 8a5.6 5.6 0 0 1 0 8"></path>
              <path class="spk__arc" data-arc d="M18.5 5.9a8.6 8.6 0 0 1 0 12.2"></path>
              <path class="spk__slash" data-slash d="M3.5 3.5l17 17"></path>
            </svg>
          </span>
        </div>
      </div>
      <div class="readout">
        <span class="readout__num" data-num>58%</span>
        <button class="readout__room" type="button" data-mute aria-pressed="false">Sonora · Living room</button>
      </div>
    </section>
    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3l13 7.4-5.7 1.4 3.3 6.4-2.4 1.2-3.3-6.4L5.7 17z"></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>

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.

20 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 “Glass capsule volume slider” 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 black there is a vertical capsule of dark glass, with a thread of light on its edge, a diagonal reflection and a soft shadow below; under the capsule the volume in figures and the name Sonora · Living room. Inside, the filled part rises from below, white fading into grey, and its surface is not straight: it is a sound wave that really flows, made of two overlapping waves, higher and faster the higher the volume, slightly lower at the sides like a liquid held by the glass, with a light line on the crest. Just below the wave there is a thin grip, at the bottom the speaker, dark when the fill covers it and light when it is left uncovered. Take the capsule and drag it up or down, without it jumping to the touched point: the capsule narrows a little under the finger, the grip squeezes, the wave wiggles faster and the fill follows the finger on a spring that overshoots by a hair; going down a light trail stays above and pulls back slowly. Pulling past the top or bottom the capsule stretches a few pixels and, let go, comes back on an elastic. The number changes and gets bolder with the volume. The speaker has one wave below 34, two up to 67, three above, and the waves come in one after another with a small bounce and shiver with the sound; at zero the wave lies flat, the speaker waves leave, the mute slash draws itself and the icon bounces, and the number turns into Muted. Past 90% the top of the fill warms to orange and a warm halo lights up above the capsule. A tap on the room name mutes and unmutes. With the keyboard the arrows move the volume, Home and End take it to zero and to the top. The autopilot pointer raises the volume into the orange, takes it down into mute and brings it back from the room name.

How it works

The fill is a path rebuilt every frame

The filled part is a closed SVG path, redrawn by the GSAP ticker with a point every two pixels: the crest is the sum of two sines (WAVELENGTH long and 1.73 times tighter) flowing with the phase, multiplied by an arch that lowers it at the sides. The same outline makes the crest line, the orange veil and, shifted, the trail.

Three springs

The drawn volume follows the wanted one on a slightly underdamped spring (stiffness 190), the trail on a slower spring (TRAIL), the wave height on a third spring: AMP times the volume, multiplied by WIGGLE while held. The phase moves by FLOW waves per second times the volume, so at zero the wave is flat and the loop stops redrawing.

The relative drag and the elastic

On pointerdown the point and the volume are remembered: the new volume is the starting one plus the movement divided by the height, as in control centres. What goes past the ends becomes a stretch (1 minus e to the minus 4 times the excess, at most 7%) anchored at the opposite end, and on release it comes back with elastic.out.

The orange and the speaker

Past HOT a value from 0 to 1 (smoothstep) lights an orange gradient in page coordinates starting at the crest and the halo above the capsule, through a CSS variable. The speaker waves come in with a staggered back.out, the mute slash draws with stroke-dashoffset and the icon bounces with elastic.out.

Values to change

NameFileDefaultWhat it changes
STARTscript.js58The starting volume, from 0 to 100.
AMPscript.js7How high the wave rises at full volume, in pixels.
WAVELENGTHscript.js46How long each wave is, in pixels.
FLOWscript.js0.8How many waves flow by per second at full volume.
WIGGLEscript.js1.7How much more it wiggles while dragged.
HOTscript.js90From which volume the top warms to orange.
TRAILscript.js38The trail spring: lower leaves the trail further behind.
STEPscript.js5How much the arrow keys move the volume.

Try them in the Playground

When to use it

In the sound panel of a music or smart speaker app, in the control centre of a home dashboard, in the controls of a video player on a phone: where the volume is set with a thumb and the control should tell, at a glance, how much sound there is.

On phones

The capsule is 84 to 104 pixels wide and at most 300 pixels or 60% of the screen tall, so with the number below it fits in the phone box. With the thumb it drags as with the mouse, without scrolling the page (touch-action: none), and the drag is relative, so it can be taken anywhere.

With reduced motion

The wave does not flow: it stays still, as high as the volume. No springs, trail, elastic or bounces: the fill goes straight where you take it, the speaker waves and the mute slash just appear; the autopilot shows the volumes one after another.

Pitfalls

  • With the crest at 100% exactly at the top the wave was cut by the edge and only dark spikes showed: a space as tall as the biggest wave always stays at the top.
  • The orange gradient in object coordinates stretched over the whole fill: it is in userSpaceOnUse and its y1 and y2 follow the crest every frame.
  • A capsule that jumps to the touched point makes an ugly leap as soon as it is taken: the drag is relative, from the volume at pointerdown.

Libraries

GSAP 3.15.0, Inter (font variabile) 5.2.5.

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

Testing

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