
The star rating
Ratings, SVG, Hover
The Appearance panel in the settings of an invented reading app, Halden: a Light, Dark and Auto segmented control. A single orb rides the pill and changes shape on a real spring: the sun pulls in its rays one by one as a shadow bites it into a crescent moon, and Auto stops halfway, a twilight. Meanwhile the panel itself takes on the chosen theme, the page thumbnail splits diagonally for Auto and the line below rolls to its new text.
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>
<!--
"Sun and moon theme picker" 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 light, dark and auto theme picker with a sun that turns into a moon on a spring</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">
<!-- the appearance setting of an invented reading app, Halden: one orb rides the pill and becomes sun, twilight or moon,
while the panel itself takes the tone of the chosen theme -->
<section class="panel" data-panel aria-labelledby="ttl">
<span class="panel__sheen" aria-hidden="true"></span>
<header class="panel__head">
<div class="panel__txt">
<h2 class="panel__title" id="ttl">Appearance</h2>
<p class="panel__sub">How Halden looks on this device</p>
</div>
<span class="thumb" data-thumb aria-hidden="true">
<span class="thumb__page thumb__page--light"><i></i><i></i><i></i></span>
<span class="thumb__page thumb__page--dark" data-thumb-dark><i></i><i></i><i></i></span>
</span>
</header>
<div class="seg" role="radiogroup" aria-label="Theme" data-seg>
<span class="seg__hover" data-hover aria-hidden="true"></span>
<span class="seg__glow" data-glow aria-hidden="true"></span>
<span class="seg__pill" data-pill aria-hidden="true"><span class="seg__shine"></span></span>
<button class="seg__opt" type="button" role="radio" aria-checked="true" tabindex="0" data-opt="0">
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"></circle><path d="M12 3.5v2M12 18.5v2M3.5 12h2M18.5 12h2M6 6l1.4 1.4M16.6 16.6 18 18M6 18l1.4-1.4M16.6 7.4 18 6"></path></svg>
<span class="seg__lbl">Light</span>
</button>
<button class="seg__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt="1">
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M19 14.6A7.5 7.5 0 0 1 9.4 5a7.5 7.5 0 1 0 9.6 9.6Z"></path></svg>
<span class="seg__lbl">Dark</span>
</button>
<button class="seg__opt" type="button" role="radio" aria-checked="false" tabindex="-1" data-opt="2">
<svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="7"></circle><path d="M12 5a7 7 0 0 1 0 14Z" class="ico__fill"></path></svg>
<span class="seg__lbl">Auto</span>
</button>
<svg class="orb" data-orb viewBox="0 0 24 24" aria-hidden="true">
<defs>
<mask id="orbMask" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
<rect width="24" height="24" fill="#fff"></rect>
<circle data-shade cx="30" cy="-6" r="6" fill="#000"></circle>
</mask>
<radialGradient id="orbFill" cx="38%" cy="34%" r="70%">
<stop offset="0" stop-color="var(--orb-hi)"></stop>
<stop offset="1" stop-color="var(--orb)"></stop>
</radialGradient>
</defs>
<g data-rays></g>
<circle data-disc cx="12" cy="12" r="4.4" fill="url(#orbFill)" mask="url(#orbMask)"></circle>
</svg>
</div>
<p class="note"><span class="note__line" data-note aria-live="polite">Always light, easy on bright days</span></p>
</section>
<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.
26 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 “Sun and moon theme picker” from Animorio and fit it into my siteSun, twilight and moon are the same SVG driven by a single number, the phase: 0 the sun, 0.5 Auto, 1 the moon. The phase gives the disc radius, the length and rotation of the eight rays (they pull in by pairs, staggered) and the position of the black circle of a mask that bites the disc. The shadow distance is piecewise, so halfway there is already a readable bite.
Phase, panel darkness, thumbnail cut and orb position are four springs integrated in requestAnimationFrame with stiffness and damping (STIFFNESS, DAMPING), the step capped at 1/30 of a second. When all of them rest the loop stops. The orb’s spring is a little stiffer than the pill, which runs on GSAP: it lands a beat later and sways a couple of pixels.
Every panel colour has a light and a dark version in :root; gsap.utils.interpolate blends them with the darkness spring and the script rewrites the CSS variables. Being a spring, the colour goes just past and back, like everything else.
The pill has two animated edges: the leading one leaves first and lands a pixel too far, the trailing one catches up, then half a wave sets them exact; the warm light under the pill follows the same edges. The Auto thumbnail is a dark page over a light one, cut by a slanted polygon clip-path.
A drawn pointer picks Dark, then Auto, presses Auto again for the wink and goes back to Light. At the first real touch, click or key it stops.
| Name | File | Default | What it changes |
|---|---|---|---|
SUN | script.js | #f4a23a | The colour of the sun and of its light under the pill. |
MOON | script.js | #c9d2ec | The colour of the moon. |
STIFFNESS | script.js | 210 | The stiffness of the spring moving sun, moon and colours. |
DAMPING | script.js | 0.62 | The spring damping: lower bounces more. |
SLIDE_TIME | script.js | 0.44 | Seconds for the pill to reach the segment. |
SUNSET | script.js | 17:04 | The time Auto switches to dark. |
PAUSE | script.js | 1.9 | Seconds the pilot stays on each theme. |
In the settings of any app or site with a dark theme: reading apps, dashboards, editors, documentation sites, the account menu. The panel taking on the theme itself shows the choice before it is applied to the page.
Same animation: the panel takes almost the full width, margins also follow the height, the track stays 48 pixels tall, a comfortable finger target.
Nothing slides or bounces: pill and orb fade out and back in on the new segment already in their final shape, the panel colours change at once and the line below crossfades.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.9 KB; the libraries: GSAP 28 KB.
Tested on 10 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.
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.