Skip to content
animorio
IT
All components

Gooey toggle switch

Toggles, Hover, PhysicsCSS only, GSAPMediumCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

22 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 “Gooey toggle switch” 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 an almost black background, in the middle, the Sound panel of an app’s settings: a very dark grey card with a thin border and three rows, Live captions, Noise reduction and Spatial audio, each with its grey line. On the right of each row a toggle: the track is a dark recessed pill and the knob is a drop of white jelly with a small highlight. A drawn pointer comes to the first row and presses: the drop squashes a touch, then stretches to the right, the neck narrows, halfway it splits in two drops with a droplet left in the middle, the first reaches the end and the second catches up and melts into it with a jelly wobble. Meanwhile the track turns from grey to violet, a soft glow of the same colour rises behind it, and the grey line under the name rewrites itself (On · English, auto-detected). On the second row the pointer drags the drop slowly, a little past the end, and the drop stretches after the finger before settling; then it switches on the third, off the first, drags the third back and switches off the second, and starts again.

How it works

The filter that melts

The 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.

Two different springs

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 and the stretch

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.

Dragging

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.

A real switch

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.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#8b7bffThe colour of the switched on track and of the glow.
SPEEDscript.js1How quick the jelly is.
STRETCHscript.js1How much the drop stretches as it runs.
SPLITscript.js1How late the second drop leaves: higher, the more they split.
GLOWscript.js1How strong the glow behind the switched on toggle is.

Try them in the Playground

When to use it

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.

On phones

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).

With reduced motion

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.

Pitfalls

  • The gooey filter goes on the drops’ group, not on the whole SVG or the track: otherwise it blurs and cuts the pill’s edge too.
  • The filter region must be widened (x and y at minus 60%, width and height 220%): with the default one, drops stretched past the edge are cut off sharply.
  • The track colours are worked out in the script, not with color-mix, which does not survive the video recording.
  • A keyboard click arrives as a click event with detail 0: it must be told apart from the pointer’s, or the toggle switches twice.

Libraries

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.

Testing

Tested on 25 October 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