Skip to content
animorio
IT
All components

Halloween mode toggle

Toggles, HoverGSAP, CanvasMediumCompressed weight: Demo 12 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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>

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.

32 values to change

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 “Halloween mode 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 warm paper there is the settings card of an invented notes app, Hollow Notes: at the top the icon with two triangle eyes and a mouth carved like a pumpkin, still unlit, then the Spooky mode row with its switch and, further down, the preview of an event, «Midnight screening». Switched on, the knob stretches, slides and settles on a spring; as it runs it becomes a full moon lit from the side, with darker seas, craters with a lit rim and a halo that breathes slowly, and the track turns into a night with three cross-shaped stars lighting up one after another. Meanwhile the page and the card softly go from paper to night, the line underneath rolls to «Lights low until Nov 1» and the pumpkin eyes light up orange as if by a flickering candle. The moon gives a small push, a thin ring opens once and a bat comes out: small with its wings closed at first, then it unfolds and grows. It is drawn like a real bat: a body with fur along the edge, a head with two pointed ears, a short muzzle, pale eyes that blink now and then, little legs, and membrane wings stretched over an arm, a forearm and four fanned fingers, with the thumb and its claw on the leading edge and a scalloped trailing edge between one finger and the next. The wings turn from the shoulder and the hand from the wrist with a small lag: down fast, up slower with the hand folding and the tip trailing, and now and then they stay open to glide; the body rises at every stroke. The flight is a soft curve: it climbs to the left, banks over the card leaning into the turn and leaves past the top corner. Switched off, the bat comes back from the left, drops towards the moon, stops beating, folds its wings, shrinks and disappears inside, the moon bounces and only then the day returns. Under the pointer the moon leans towards the other end; pressed, it shrinks. A drawn pointer switches it on and off by itself; it works with the mouse, touch and the keyboard.

How it works

The theme as variables

The 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 that becomes the moon

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.

A real wing, on a canvas

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 and the bank

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.

Values to change

NameFileDefaultWhat it changes
APPscript.jsHollow NotesThe app name at the top.
TITLEscript.jsSpooky modeThe toggle’s name.
HINT_OFFscript.jsPlain eveningsThe line underneath when off.
HINT_ONscript.jsLights low until Nov 1The line underneath when on.
ACCENTscript.js#ff7a1aThe pumpkin orange of the bat and the eyes.
SPRINGscript.js0.62How much the knob bounces: lower is springier.
FLIGHTscript.js2.6How many seconds the bat’s flight lasts.
BAT_SIZEscript.js1How big the bat is in flight.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • GSAP writes its own inline transform: the knob is placed with left and top and GSAP only moves its x and width; the press scale sits on the child, the face.
  • Switching off, the day returns only once the bat is back inside the moon: if the theme changed at once, the orange bat would fly over an already light page.
  • The colour of the unlit eyes comes from the day values read at the start, not from the current style, which is halfway during the change.
  • The moon is a whole SVG: to turn it GSAP uses transformOrigin at the centre; with svgOrigin on the root SVG the rotation started from another point and for a moment two discs showed.
  • The bat’s canvas is redrawn on the GSAP ticker and sized with devicePixelRatio (up to 2.5): so the bat stays sharp even when zoomed.

Libraries

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.

Testing

Tested on 30 October 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