
The layered button
Buttons, Hover, Physics
The sound settings panel of an app, on black, with three toggles whose knob is a drop of white jelly: pressed, the drop stretches towards the other side, splits in two halfway with a droplet pinched in the neck, and the two melt back together at the far end with a wobble, while the track lights up violet and a soft glow rises behind it. It can also be dragged with a finger, and the drop stretches after the pointer.
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>
<!--
"Gooey toggle switch" 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 gooey toggle switch that melts across</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>
<!-- the gooey filter shared by every toggle: blur the blobs, then sharpen the alpha so close blobs melt together -->
<svg class="defs" aria-hidden="true" focusable="false">
<filter id="goo" x="-60%" y="-60%" width="220%" height="220%" color-interpolation-filters="sRGB">
<feGaussianBlur in="SourceGraphic" stdDeviation="3.2" result="blur"></feGaussianBlur>
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -9" result="goo"></feColorMatrix>
</filter>
</svg>
<main class="stage">
<!-- a real settings panel on near black: three rows, each with a toggle whose knob is a drop of jelly.
Switched, the drop stretches, splits in two halfway and the two drops melt back together on the other side -->
<section class="panel" data-panel aria-label="Sound settings">
<header class="panel__head">
<h1 class="panel__title">Sound</h1>
<p class="panel__sub">Applies to calls and recordings</p>
</header>
<div class="row" data-row>
<div class="row__text">
<p class="row__name" id="r1">Live captions</p>
<p class="row__note" data-note data-off="Show words as people speak" data-on="On · English, auto-detected">Show words as people speak</p>
</div>
<button class="goo" type="button" role="switch" aria-checked="false" aria-labelledby="r1" data-toggle>
<span class="goo__glow" aria-hidden="true"></span>
<span class="goo__track" aria-hidden="true"></span>
<svg class="goo__blobs" viewBox="0 0 72 40" aria-hidden="true">
<g filter="url(#goo)">
<ellipse class="goo__drop" data-a cx="20" cy="20" rx="13" ry="13"></ellipse>
<ellipse class="goo__drop" data-b cx="20" cy="20" rx="13" ry="13"></ellipse>
<circle class="goo__drop" data-c cx="20" cy="20" r="0"></circle>
</g>
<ellipse class="goo__shine" data-shine cx="17" cy="15" rx="5" ry="3"></ellipse>
</svg>
</button>
</div>
<div class="row" data-row>
<div class="row__text">
<p class="row__name" id="r2">Noise reduction</p>
<p class="row__note" data-note data-off="Background sound comes through" data-on="Filtering keyboards and traffic">Background sound comes through</p>
</div>
<button class="goo" type="button" role="switch" aria-checked="false" aria-labelledby="r2" data-toggle>
<span class="goo__glow" aria-hidden="true"></span>
<span class="goo__track" aria-hidden="true"></span>
<svg class="goo__blobs" viewBox="0 0 72 40" aria-hidden="true">
<g filter="url(#goo)">
<ellipse class="goo__drop" data-a cx="20" cy="20" rx="13" ry="13"></ellipse>
<ellipse class="goo__drop" data-b cx="20" cy="20" rx="13" ry="13"></ellipse>
<circle class="goo__drop" data-c cx="20" cy="20" r="0"></circle>
</g>
<ellipse class="goo__shine" data-shine cx="17" cy="15" rx="5" ry="3"></ellipse>
</svg>
</button>
</div>
<div class="row" data-row>
<div class="row__text">
<p class="row__name" id="r3">Spatial audio</p>
<p class="row__note" data-note data-off="Voices come from the centre" data-on="Voices placed around you">Voices come from the centre</p>
</div>
<button class="goo" type="button" role="switch" aria-checked="false" aria-labelledby="r3" data-toggle>
<span class="goo__glow" aria-hidden="true"></span>
<span class="goo__track" aria-hidden="true"></span>
<svg class="goo__blobs" viewBox="0 0 72 40" aria-hidden="true">
<g filter="url(#goo)">
<ellipse class="goo__drop" data-a cx="20" cy="20" rx="13" ry="13"></ellipse>
<ellipse class="goo__drop" data-b cx="20" cy="20" rx="13" ry="13"></ellipse>
<circle class="goo__drop" data-c cx="20" cy="20" r="0"></circle>
</g>
<ellipse class="goo__shine" data-shine cx="17" cy="15" rx="5" ry="3"></ellipse>
</svg>
</button>
</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.
22 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 “Gooey toggle switch” from Animorio and fit it into my siteThe drops are three white ellipses in an SVG inside a group with the gooey filter: a feGaussianBlur of 3.2 softens them and a feColorMatrix multiplies the alpha by 22 and takes away 9, so what was blurred becomes sharp again. Where two drops are close their halos add up and become a neck; as they move apart the neck thins and breaks by itself.
The leading drop follows a stiff spring with almost no bounce, the trailing one a soft spring with more bounce, and it leaves 0.17 seconds late: that delay is what splits the drops halfway, and the soft spring is what makes them wobble when they meet again. The springs are worked out on every frame on GSAP’s ticker, in two half steps to stay steady even at low frame rates.
The droplet in the neck has no life of its own: its radius is a sine of the distance between the two drops, it exists only while they split and vanishes when they rejoin. Each drop stretches in proportion to its speed and flattens as much, and both shrink a little while apart, as if they were sharing the jelly.
Pressed and moved by more than three pixels, the toggle becomes draggable: the leading drop follows the finger (with pointer capture, even outside the button) and the trailing one chases it on its spring. Released, it switches on or off depending on which half it is in. The track colour and the glow follow the drops’ position, so they show halfway too.
Each toggle is a button with role switch and aria-checked, tied to its row’s name; on the keyboard Space and Enter change it. The first touch or key stops the autopilot. With reduced motion the drops jump into place without running and only the colour and the glow change.
| Name | File | Default | What it changes |
|---|---|---|---|
ACCENT | script.js | #8b7bff | The colour of the switched on track and of the glow. |
SPEED | script.js | 1 | How quick the jelly is. |
STRETCH | script.js | 1 | How much the drop stretches as it runs. |
SPLIT | script.js | 1 | How late the second drop leaves: higher, the more they split. |
GLOW | script.js | 1 | How strong the glow behind the switched on toggle is. |
For the settings of an app that wants a touch of material without losing its seriousness: a calls or music app, an AI assistant, the preferences panel of a product on a dark background.
The card takes up almost the whole width and the grey lines shorten with an ellipsis; the toggles stay as big as on the computer. A tap presses and switches, and a finger drags the drop (the button has touch-action none, so the page does not scroll over the toggle).
The drops jump straight into place without stretching or splitting; only the track colour and the glow change, and the grey line rewrites itself without sliding. The drawn pointer does not appear.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.8 KB; the libraries: GSAP 28 KB.
Tested on 25 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.