Skip to content
animorio
IT
All components

Soft emboss toggle

Toggles, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.7 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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 &amp; 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>

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.

27 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Soft emboss toggle” 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 a cool light grey background sits a soft raised card, made of the same paper, with the small title “Display & sync” and three rows: Night mode, Auto-brightness and Sync over Wi-Fi, each with its drawn icon in a hollow well, the name, a line below, the word Off and the switch. The rows are divided by an engraved line, dark with a light one under it. The switch’s track is a hollow with the shadow inside; the round knob is raised, with a light shadow top left and a dark one bottom right, and an engraved notch in the middle. On hover the knob rises a pixel and its shadows stretch; held down it flattens and widens. On release it slides right on a spring, stretching on the way and coming back together, goes a pixel past and settles; then it sinks: its shadows shorten while the hollow behind it gets darker and deeper on the on side, with a veil of blue. A thin filament of blue light draws along the track’s lower rim and stays lit, still. The knob’s notch turns blue, the word rolls from Off to On and the icon takes colour: the moon tilts and a little star appears, the sun’s rays make an eighth of a turn, the Wi-Fi arcs light up one after another. On its own it switches the three rows on in a staggered rhythm and off in another order: the filament goes out first, the knob slides back and rises into relief again.

How it works

Everything from variables

The 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 movement in CSS

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.

The spring and the stretch

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.

The widening hollow

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 filament of light

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.

Values to change

NameFileDefaultWhat it changes
KNOB_RELIEFscript.js5How raised the knob is when off, in pixels.
SINKscript.js2.4How raised it stays when on, after it has sunk.
TRACK_DEPTHscript.js3How deep the track’s hollow is when off.
SPRINGscript.js1.3How far the knob overshoots as it arrives.
SLIDE_TIMEscript.js0.55How long the knob takes to slide, in seconds.
SQUISHscript.js1.14How much the knob widens while held down.
STAGGERscript.js0.6The self-running rhythm between one switch and the next.
LOOP_PAUSEscript.js1.6The pause with everything off before the loop starts again.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • Outer and inset shadows don’t interpolate into each other: the knob and the track always keep their own, and only the lengths are animated through CSS variables.
  • GSAP’s inline transform would have wiped the movement written in the CSS: the knob has no transform tween, GSAP only animates numbers and the whole transform lives in the CSS with the variables.
  • With a round cap the filament at zero stayed as a blue dot at the end of the track: the caps are flat and at zero the filament is hidden.
  • Neumorphism needs a background the same colour as its pieces: on pure white the light shadow disappears, so the background is a light grey and the text is dark to stay readable.

Libraries

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.

Testing

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