Skip to content
animorio
IT
All components

Neumorphic toggle

Toggles, HoverGSAP, CSS onlyEasyCompressed weight: Demo 4.5 KBGSAP 28 KBFreeDownload the zip

A soft-relief switch, carved into a pale plate. Touch it and the knob sinks (its shadow pulls in), slides across on a spring and comes back up; behind it the groove fills with green and the inner shadow widens. The knob’s three ridges light up and the word under “Quiet mode” rolls from Off to On. It can also be dragged.

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>
<!--
  "Neumorphic 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>Neumorphic 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>
  <main class="stage">
    <!-- a soft-relief switch: the knob sinks before it slides, the groove fills with colour behind it and
         the inner shadow widens; it can be clicked, dragged or flipped with the keyboard -->
    <div class="np" data-np>
      <div class="np__text">
        <span class="np__label" id="np-label">Quiet mode</span>
        <span class="np__state" aria-hidden="true"><b data-state>Off</b></span>
      </div>
      <button class="nt" type="button" role="switch" aria-checked="false" aria-labelledby="np-label" data-nt>
        <span class="nt__fill" data-fill aria-hidden="true"></span>
        <span class="nt__carve" aria-hidden="true"></span>
        <span class="nt__knob" data-knob aria-hidden="true"><span class="nt__dimple" data-dimple><i></i><i></i><i></i></span></span>
      </button>
    </div>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></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.

11 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 “Neumorphic 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 white, a pale grey plate with round corners, lifted by a soft shadow: on the left “Quiet mode” and under it “Off”, on the right the switch, a carved groove with shadow top left and light bottom right, and inside it a raised white knob with a small hollow and three ridges. Press it and the knob’s shadow pulls in as if it sank into the plate; then it slides right, just overshoots and settles, and its shadow returns. As it passes, the groove behind it fills with teal, the inner shadow grows wider and darker, the three ridges turn green and “Off” rolls away for “On”. The plate gives by a breath. Another tap and everything goes back. Hold the knob and it follows the finger: let go past halfway and it stays on, before that it goes back off.

How it works

One number

The knob’s position is a number from 0 to 1: it moves the knob and is written to the CSS variable --on, from which the groove’s colour, its clipping and the inner shadow work themselves out.

The sink

A second number, --lift, multiplies the measures of the knob’s shadow: it drops to 0.25 in a tenth of a second, then rises on a back.out while the knob is already sliding.

The relief

Every shadow has two halves: dark bottom right and light top left for what stands out, inset and reversed for what is carved. The layer of inner shadows sits above the colour.

The drag

pointerdown captures the pointer, pointermove shifts the number by how far the finger moved divided by the travel; on release the halfway point decides. Under four pixels it is a tap.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#19c2a0The colour that fills the groove when the switch is on.
DEPTHscript.js1How deep the relief is (the shadows): 0.5 = barely there, 1.6 = pronounced.
SPRINGscript.js1How much the knob bounces when it arrives: 0.3 = a little, 2 = a lot.
START_ONscript.jsfalsetrue = the switch starts on.
LOOPscript.jstrueLeft alone, the demo’s pointer turns it on and off.

Try them in the Playground

When to use it

In the settings of a home app, a car, a music player or any product with a soft, tactile look: one entry with its switch, to repeat down a list.

On phones

The same plate, 272 pixels wide at most; the switch is 104 by 56, easy for a thumb, and with a finger it can be tapped or dragged.

With reduced motion

The knob goes straight to the other side, with no sink and no bounce; groove, ridges and word change together. No dragging. The demo does not move by itself.

Pitfalls

  • Soft relief is low-contrast by nature: the state must not live in the shadows alone. Here the groove’s colour and the word On or Off say it too.
  • It is a button with role switch and aria-checked: Space and Enter flip it, and its name comes from the label through aria-labelledby.
  • The relief only works if plate and switch are nearly the same colour and the light always comes from the same corner.
  • The shadows are worked out with calc and CSS variables: animating box-shadow directly with GSAP would cost more and be less precise.
  • After a drag the browser still sends a click: a variable has it ignored, or the switch would flip twice.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 4.5 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