
The inchworm menu
Menus, Hover, Transitions
A real button for the light theme, a pill with the icon and the label: on the dark theme it says «Light mode» with a thin moon. Tap it and it squeezes on a spring, the moon turns, the bite of the crescent slides away and the body shrinks into the core of a sun, the rays fan open one after another, a degree past their place, and settle. From the centre of the icon a warm light spreads in a circle over the whole page, and the example card behind turns to the light theme with it; the label becomes «Dark mode». A second tap brings the night back the same way. A single sun-coloured accent.
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>
<!--
"Light mode button" 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>Light mode button</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 light that spreads from the icon over the page when the theme changes -->
<span class="flood" data-flood aria-hidden="true"></span>
<main class="stage">
<div class="group" data-gruppo>
<!-- a small page card behind the button, so the change of theme has something to land on -->
<article class="note" data-note aria-label="Example page">
<span class="note__edge" aria-hidden="true"></span>
<span class="note__kicker">Field journal</span>
<h1 class="note__title">Evening on the ridge</h1>
<p class="note__line">The wind drops after six and the valley goes quiet.</p>
<p class="note__line note__line--short">Two more miles to the hut.</p>
</article>
<!-- the light mode button: a real pill with the icon and the label -->
<button class="pill" type="button" aria-pressed="false" data-pill>
<span class="pill__bg" data-bg aria-hidden="true"></span>
<span class="pill__shine" data-shine aria-hidden="true"></span>
<span class="pill__in">
<svg class="icon" data-icon viewBox="0 0 24 24" aria-hidden="true">
<defs>
<mask id="falce" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
<rect width="24" height="24" fill="#fff"/>
<circle data-bite cx="16.6" cy="7.4" r="6.4" fill="#000"/>
</mask>
</defs>
<g data-rays></g>
<circle class="icon__body" data-body cx="12" cy="12" r="7.2" mask="url(#falce)"/>
</svg>
<span class="pill__labels" data-labels>
<span class="pill__label" data-to-light>Light mode</span>
<span class="pill__label" data-to-dark aria-hidden="true">Dark mode</span>
</span>
</span>
</button>
</div>
</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.
17 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 “Light mode button” from Animorio and fit it into my siteA circle with a mask: with the bite of the mask inside it is a crescent, with the bite moved out and the radius going from 7.2 to 4.6 it is the core of the sun. The rays are lines drawn around the true centre (12, 12) and turned with svgOrigin.
A fixed circle under the page, centred on the measured centre of the icon and as big as the distance to the farthest corner, scales from zero to one; it is a radial gradient with the colour of the new theme and a warm rim.
The colours of page, card and pill are CSS variables on the root: GSAP takes them from the dark to the light theme as the light passes, and at the end only the .chiaro class is left.
«Light mode» and «Dark mode» sit on top of each other, absolutely positioned, inside a box as wide as the longer one, measured: icon and label stay in the centre of the pill in every state.
| Name | File | Default | What it changes |
|---|---|---|---|
RAYS | script.js | 8 | How many rays open around the sun, from 4 to 12. |
FILL | script.js | 0.95 | Seconds for the light (or the night) to cover the page. |
SPRING | script.js | 0.5 | How springy the press and the rays are (lower = more bounce). |
RAY_STAGGER | script.js | 0.045 | Seconds between one ray and the next as they fan open. |
START_LIGHT | script.js | false | Start in the light theme instead of the dark one. |
IDLE | script.js | 6 | Seconds after your last touch before the demo plays by itself again. |
On a site or app with a dark and a light theme: in the top bar, in the settings menu or at the bottom of the page, when changing theme should be a button with its own label rather than a switch.
Everything is in em and the size depends on both the width and the height of the window; the light is measured on every tap from the true centre of the icon, so it covers the page at any size.
No circle of light, no springs and no fanning rays: the icon swaps with a fade and the page fades to the other theme.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 6.6 KB; the libraries: GSAP 28 KB.
Tested on 30 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.