
The elastic button
Buttons, Hover, Text
Someone searched for “neumorphism” and none of the toggles was in that style. Three settings rows of a made-up reading app, Night mode, Auto-brightness and Sync over Wi-Fi, in neumorphic style (soft UI): the card, the tracks and the knobs are made of the same light grey paper as the background. The track is a hollow, the knob is raised by two soft shadows. Switched on, the knob slides on a spring, stretches a little on the way and sinks into the surface: the hollow deepens towards the on side and a thin filament of blue light stays lit on the track’s lower rim. The label rolls from Off to On and each icon makes its own small gesture: the moon tilts with a little star, the sun’s rays turn, the Wi-Fi arcs light up one after another.
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>
<!--
"Soft emboss toggle" 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>Soft emboss toggle</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>
<svg class="sr" aria-hidden="true" focusable="false">
<defs>
<!-- the filament is faint at the off end and brightest under the knob -->
<linearGradient id="filo" x1="0" y1="0" x2="1" y2="0">
<stop offset="0" stop-color="#4f7cf7" stop-opacity="0.12"></stop>
<stop offset="0.55" stop-color="#4f7cf7" stop-opacity="0.7"></stop>
<stop offset="1" stop-color="#4f7cf7" stop-opacity="1"></stop>
</linearGradient>
</defs>
</svg>
<main class="stage">
<!-- three rows of settings of a made-up reading app, soft UI style: everything is the same paper as the background;
the track of every switch is a hollow, the knob is raised; switched on, the knob slides on a spring and sinks,
the hollow deepens towards the on side and a thin filament of light stays lit on its lower rim -->
<section class="group" data-group aria-label="Display and sync">
<p class="group__title">Display & sync</p>
<ul class="rows">
<li class="row" data-row>
<span class="well" aria-hidden="true">
<svg class="ico" viewBox="0 0 24 24" data-ico="moon">
<g data-moon><path d="M19.2 14.6A7.4 7.4 0 1 1 9.4 4.8a6 6 0 0 0 9.8 9.8z"></path></g>
<path class="ico__spark" d="M17.2 4.2v2.6M15.9 5.5h2.6" data-spark></path>
</svg>
</span>
<span class="row__text">
<span class="row__name" id="name-night">Night mode</span>
<span class="row__sub">Warmer pages after sunset</span>
</span>
<span class="state" aria-hidden="true"><span class="state__line">Off</span></span>
<button class="switch" type="button" role="switch" aria-checked="false" aria-labelledby="name-night" data-switch>
<span class="switch__deep" aria-hidden="true"></span>
<svg class="switch__rim" viewBox="0 0 58 32" aria-hidden="true">
<path class="rim__light" pathLength="1" d="M1.25 16A14.75 14.75 0 0 0 16 30.75H42A14.75 14.75 0 0 0 56.75 16"></path>
</svg>
<span class="knob" aria-hidden="true"><span class="knob__face"></span><span class="knob__grip"></span></span>
</button>
</li>
<li class="row" data-row>
<span class="well" aria-hidden="true">
<svg class="ico" viewBox="0 0 24 24" data-ico="sun">
<circle cx="12" cy="12" r="3.5"></circle>
<g data-rays><path d="M12 3.6v1.9M12 18.5v1.9M3.6 12h1.9M18.5 12h1.9M6.1 6.1l1.3 1.3M16.6 16.6l1.3 1.3M6.1 17.9l1.3-1.3M16.6 7.4l1.3-1.3"></path></g>
</svg>
</span>
<span class="row__text">
<span class="row__name" id="name-bright">Auto-brightness</span>
<span class="row__sub">Follows the light in the room</span>
</span>
<span class="state" aria-hidden="true"><span class="state__line">Off</span></span>
<button class="switch" type="button" role="switch" aria-checked="false" aria-labelledby="name-bright" data-switch>
<span class="switch__deep" aria-hidden="true"></span>
<svg class="switch__rim" viewBox="0 0 58 32" aria-hidden="true">
<path class="rim__light" pathLength="1" d="M1.25 16A14.75 14.75 0 0 0 16 30.75H42A14.75 14.75 0 0 0 56.75 16"></path>
</svg>
<span class="knob" aria-hidden="true"><span class="knob__face"></span><span class="knob__grip"></span></span>
</button>
</li>
<li class="row" data-row>
<span class="well" aria-hidden="true">
<svg class="ico" viewBox="0 0 24 24" data-ico="wifi">
<path d="M10.3 17.2a2.4 2.4 0 0 1 3.4 0" data-arc></path>
<path d="M7.5 14.2a6.4 6.4 0 0 1 9 0" data-arc></path>
<path d="M4.7 11.2a10.4 10.4 0 0 1 14.6 0" data-arc></path>
</svg>
</span>
<span class="row__text">
<span class="row__name" id="name-sync">Sync over Wi-Fi</span>
<span class="row__sub">Saves your notes and bookmarks</span>
</span>
<span class="state" aria-hidden="true"><span class="state__line">Off</span></span>
<button class="switch" type="button" role="switch" aria-checked="false" aria-labelledby="name-sync" data-switch>
<span class="switch__deep" aria-hidden="true"></span>
<svg class="switch__rim" viewBox="0 0 58 32" aria-hidden="true">
<path class="rim__light" pathLength="1" d="M1.25 16A14.75 14.75 0 0 0 16 30.75H42A14.75 14.75 0 0 0 56.75 16"></path>
</svg>
<span class="knob" aria-hidden="true"><span class="knob__face"></span><span class="knob__grip"></span></span>
</button>
</li>
</ul>
</section>
<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>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.
27 values to change
Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI
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 “Soft emboss toggle” from Animorio and fit it into my siteThe track and the knob each have a single box-shadow, written in CSS with calc from variables: --i for the depth of the hollow, --o for the knob’s relief, --p for its position, --y, --sx and --sy to lift and squash it. The script keeps these numbers in one object per switch and GSAP animates them, writing the variables on every frame.
The knob moves with translateX(calc(var(--run) * var(--p))), where --run is the travel computed from the track’s size: no pixels in the script, so nothing to recompute on resize.
In one timeline --p goes to 1 with back.out, while the knob widens by 10% in the first third of the trip and comes back with elastic.out: a pixel past and the settle. Then --o drops below its value and climbs back a touch: the knob sinks.
Inside the track a second layer with a darker inset shadow is as wide as the way the knob has travelled, calc(var(--k) + var(--run) * var(--p)), and fades in with --d: the hollow deepens towards the on side.
The track’s lower rim is an SVG path with pathLength 1 that draws by taking strokeDashoffset from 1 to 0, autoRound off; the caps are flat and at zero the filament hides, so no dot is left behind.
| Name | File | Default | What it changes |
|---|---|---|---|
KNOB_RELIEF | script.js | 5 | How raised the knob is when off, in pixels. |
SINK | script.js | 2.4 | How raised it stays when on, after it has sunk. |
TRACK_DEPTH | script.js | 3 | How deep the track’s hollow is when off. |
SPRING | script.js | 1.3 | How far the knob overshoots as it arrives. |
SLIDE_TIME | script.js | 0.55 | How long the knob takes to slide, in seconds. |
SQUISH | script.js | 1.14 | How much the knob widens while held down. |
STAGGER | script.js | 0.6 | The self-running rhythm between one switch and the next. |
LOOP_PAUSE | script.js | 1.6 | The pause with everything off before the loop starts again. |
In the settings of an app or a dashboard in soft UI style, on a smart home panel, a player or a reading app, in account preferences, or anywhere a soft, tactile switch should replace a flat one.
Under 400 pixels wide the lines under the names go and the card takes the width minus a margin: everything fits the phone preview box, shadows included. The whole row is tappable: as the finger lands the knob squashes, on release it slides.
No movement or springs: the three rows are shown already on, filaments lit; tapped, the knob jumps to the other side without sliding, shadows and colours fade and the word crossfades without rolling. The self-running loop doesn’t start.
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 22 November 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.
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.