
The elastic button
Buttons, Hover, Text
The Spooky mode toggle of an invented notes app, for Halloween, in the style of product interface pieces: switched on, the knob turns into a cratered full moon and slides on a spring, the track becomes a night with three thin stars and the page softly turns to night; a real bat leaves the moon, with membrane wings stretched over its fingers, unfolds, beats its wings from the shoulder and flies on an arc with a banking turn. Switched off, the bat comes back, folds its wings and goes back into the moon.
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>
<!--
"Halloween mode 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>The Spooky mode toggle with a bat leaving the moon</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" data-stage>
<!-- the appearance settings of an invented notes app: switching Spooky mode on turns the knob into a full moon,
the track into a night with a few thin stars, the page into the night, and a bat with membrane wings leaves
the moon and flies across the page; switching it off brings the bat back into the moon -->
<section class="card" data-card aria-labelledby="sp-label">
<header class="head">
<span class="appico" aria-hidden="true">
<svg viewBox="0 0 28 28">
<rect class="appico__box" x="1" y="1" width="26" height="26" rx="8"></rect>
<g class="appico__eyes" data-eyes>
<path d="M7.4 13.6 10.2 8.8 13 13.6Z"></path>
<path d="M15 13.6 17.8 8.8 20.6 13.6Z"></path>
<path class="appico__mouth" d="M8.6 17.6c1.6 1.4 3.4 2 5.4 2s3.8-.6 5.4-2l-1.6 1.1-1.3-1-1.2 1.1-1.3-1-1.3 1-1.2-1.1-1.3 1Z"></path>
</g>
</svg>
</span>
<span class="head__text">
<span class="head__app" data-app>Hollow Notes</span>
<span class="head__sub">Appearance</span>
</span>
</header>
<div class="row">
<span class="row__text">
<span class="row__title" id="sp-label" data-title>Spooky mode</span>
<span class="row__hint"><span data-hint>Plain evenings</span></span>
</span>
<button class="sw" data-switch role="switch" aria-checked="false" aria-labelledby="sp-label">
<span class="sw__night" data-night aria-hidden="true">
<svg class="sw__stars" viewBox="0 0 64 34">
<path data-star d="M12 9.2v3.6M10.2 11h3.6"></path>
<path data-star d="M21 21.4v2.8M19.6 22.8h2.8"></path>
<path data-star d="M7.4 23.6v2.2M6.3 24.7h2.2"></path>
</svg>
</span>
<span class="sw__knob" data-knob aria-hidden="true">
<span class="sw__halo" data-halo></span>
<span class="sw__ring" data-ring></span>
<span class="sw__face" data-face>
<svg class="sw__moon" viewBox="0 0 26 26" data-moon>
<defs>
<radialGradient id="moon-light" cx="38%" cy="34%" r="72%">
<stop offset="0" stop-color="#fbf5e8"></stop>
<stop offset="0.62" stop-color="#efe4cc"></stop>
<stop offset="1" stop-color="#d6c6a4"></stop>
</radialGradient>
<clipPath id="moon-clip"><circle cx="13" cy="13" r="12"></circle></clipPath>
</defs>
<circle class="moon__disc" cx="13" cy="13" r="12" fill="url(#moon-light)"></circle>
<g clip-path="url(#moon-clip)">
<path class="moon__mare" d="M5.6 8.2c1.6-2.6 4.6-3 6.3-1.6 1.2 1-.2 2.6-1.9 3.1-1.6.5-2.2 2-3.6 1.6-1.2-.3-1.6-1.6-.8-3.1Z"></path>
<path class="moon__mare" d="M13.8 13.4c1.8-.9 4.4-.5 5.3 1.1.8 1.5-.4 3.4-2.4 3.6-1.6.2-2.1-1-3-1.4-1-.5-1.4-2.4.1-3.3Z"></path>
<path class="moon__mare moon__mare--soft" d="M8.2 17.6c1.2-.6 2.8-.2 3.1.9.3 1-.8 2-2.1 1.9-1.4-.1-2.2-2.1-1-2.8Z"></path>
<g class="moon__crater"><circle cx="9.2" cy="9.8" r="2.1"></circle><path d="M7.4 9.1a2.1 2.1 0 0 1 3.1-.9"></path><path d="M11.1 10.6a2.1 2.1 0 0 1-2.6 1.1"></path></g>
<g class="moon__crater"><circle cx="16.6" cy="15.4" r="1.5"></circle><path d="M15.3 14.9a1.5 1.5 0 0 1 2.2-.7"></path><path d="M17.9 16a1.5 1.5 0 0 1-1.8.9"></path></g>
<g class="moon__crater moon__crater--small"><circle cx="11.4" cy="18.6" r=".9"></circle></g>
<g class="moon__crater moon__crater--small"><circle cx="18.4" cy="8.6" r=".7"></circle></g>
<circle class="moon__terminator" cx="17.2" cy="15.6" r="12.6"></circle>
</g>
<circle class="moon__rim" cx="13" cy="13" r="11.6"></circle>
</svg>
</span>
</span>
</button>
</div>
<div class="preview" data-preview>
<span class="preview__time">Oct 31 · 23:30</span>
<span class="preview__title">Midnight screening</span>
<span class="preview__line"></span>
<span class="preview__line preview__line--short"></span>
</div>
</section>
<canvas class="bats" data-bats aria-hidden="true"></canvas>
<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>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.
32 values to change
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 “Halloween mode toggle” from Animorio and fit it into my siteThe day and night colours live in :root as variables; switching on, GSAP takes every day variable to its night value in 0.85 seconds, so page, card, text and rules change together without a class snapping.
The knob first stretches and runs, then settles with elastic.out; over it the SVG moon appears turning from minus 40 degrees, the white of the knob fades and a pale halo remains. The stars on the track are three small crosses growing staggered with back.out.
The bat is drawn every frame on a page-sized canvas: one right wing made of shoulder, elbow, wrist and four fanned fingers, mirrored for the left one. The arm turns from the shoulder, the hand turns again from the wrist with a lag and folds on the way up; the membrane runs from the arm to the tip and back to the hip with a concave arc between one finger and the next.
The flight goes through six points around the card, joined by a Catmull-Rom curve and measured by length, so the speed is even; the bank comes from the curvature through a spring, the wingbeat follows a fixed pattern of strokes and glides and the body rises and sinks on another spring.
| Name | File | Default | What it changes |
|---|---|---|---|
APP | script.js | Hollow Notes | The app name at the top. |
TITLE | script.js | Spooky mode | The toggle’s name. |
HINT_OFF | script.js | Plain evenings | The line underneath when off. |
HINT_ON | script.js | Lights low until Nov 1 | The line underneath when on. |
ACCENT | script.js | #ff7a1a | The pumpkin orange of the bat and the eyes. |
SPRING | script.js | 0.62 | How much the knob bounces: lower is springier. |
FLIGHT | script.js | 2.6 | How many seconds the bat’s flight lasts. |
BAT_SIZE | script.js | 1 | How big the bat is in flight. |
For a dark theme or seasonal theme switch in an app or a site, above all for Halloween: appearance settings, a night-time event, a shop with its Halloween week.
The card takes the width with a margin and the gaps are sized on the height too with clamp and vmin, so it fits in the box; the bat’s flight is computed on the window at that moment. Touch works like a click.
No flight, springs or flicker: the knob goes to its place, the moon, the stars and the night fade in and the eyes light up steady. The fake pointer does not start.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 12 KB; the libraries: GSAP 28 KB.
Tested on 30 October 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.
Support Animorio
Animorio stays free thanks to the people who support it. If you like, buy us a coffee: it helps us make the next animations.
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.