
The send button
Buttons, Transitions, SVG
NewFree
A switch drawn as a little landscape: turned on, the sun slides across and becomes the moon, the day clouds drift away, the hills turn blue, and the night spreads over the whole page in a circle that starts from the switch.
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>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The day and night switch</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/nunito@5.3.0/index.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- the day and the night of the page: a white layer, and over it a black circle that grows out of the switch and
shrinks back into it -->
<span class="day" aria-hidden="true"></span>
<span class="night" aria-hidden="true" data-night></span>
<main class="stage">
<!-- the switch: a little landscape. Turned on, the sun slides across and turns into the moon, the day clouds drift
off and the night ones come in, the hills darken, and the whole page goes black -->
<div class="theme" data-theme>
<button class="sky" type="button" role="switch" aria-checked="false" aria-labelledby="sky-label" data-sky data-autoclic>
<span class="sky__day" aria-hidden="true"></span>
<span class="sky__dark" aria-hidden="true" data-dark></span>
<svg class="sky__land" viewBox="0 0 132 56" preserveAspectRatio="none" aria-hidden="true">
<g data-day-clouds>
<path class="cloud" transform="translate(76 9)" d="M6 12a5 5 0 0 1 4.6-5 6.5 6.5 0 0 1 12.2-1.4A4.6 4.6 0 0 1 28 12z"/>
<path class="cloud" transform="translate(98 20) scale(0.75)" d="M6 12a5 5 0 0 1 4.6-5 6.5 6.5 0 0 1 12.2-1.4A4.6 4.6 0 0 1 28 12z"/>
</g>
<g data-night-clouds>
<path class="cloud cloud--night" transform="translate(10 8) scale(0.8)" d="M6 12a5 5 0 0 1 4.6-5 6.5 6.5 0 0 1 12.2-1.4A4.6 4.6 0 0 1 28 12z"/>
<path class="cloud cloud--night" transform="translate(30 20) scale(0.6)" d="M6 12a5 5 0 0 1 4.6-5 6.5 6.5 0 0 1 12.2-1.4A4.6 4.6 0 0 1 28 12z"/>
</g>
<path class="hill hill--back" d="M0 56V44c18-7 36-8 58-2s46-6 74-1v15z"/>
<path class="hill hill--front" d="M0 56v-7c24-4 48 4 74 0s40-5 58-1v8z"/>
<path class="hill hill--back-night" data-night-hill d="M0 56V44c18-7 36-8 58-2s46-6 74-1v15z"/>
<path class="hill hill--front-night" data-night-hill d="M0 56v-7c24-4 48 4 74 0s40-5 58-1v8z"/>
</svg>
<span class="sky__thumb" data-thumb>
<span class="sky__knob" data-knob>
<svg viewBox="-24 -24 48 48" aria-hidden="true">
<g class="sun-rays" data-rays></g>
<circle class="disc" r="13.5" data-disc/>
<g class="craters" data-craters>
<circle cx="-4.5" cy="-3.5" r="3.2"/>
<circle cx="4.8" cy="3.6" r="2.2"/>
<circle cx="-2" cy="6.4" r="1.5"/>
</g>
</svg>
</span>
</span>
</button>
<span class="theme__label" id="sky-label" data-label>Dark mode</span>
</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.
10 values to change
With the Animorio connector, Claude Code takes it from here, guide included, and fits it into your project. Paste this request:
Take “The day and night switch” from Animorio and fit it into my siteThe button (role switch) holds two gradient backgrounds, day and night one over the other, an SVG with the clouds and two pairs of hills, and the knob: an SVG with the disc, the rays made by the script and three craters. The knob sits inside a second element that takes the press and the peek towards the other side, so they never clash with the slide.
The whole change from day to night is one paused timeline: turning on plays it forwards, turning off backwards, and a click halfway turns it round from where it is. The knob slides in three quarters of TIME, stretching up to STRETCH halfway; the rays shrink and turn by 90 degrees, the disc changes colour and the craters appear with back.out.
Behind everything there are two fixed layers: the white of the day and the black night, cut by a clip-path circle centred on the switch. The radius goes from zero to the distance of the window’s farthest corner; in the timeline a number from 0 to 1 draws it on every frame.
The words are white with mix-blend-mode difference: on white they turn black, on black they stay white, and while the night passes they split right on the edge of the circle. That is why the day’s white is a real layer and not just the page background, and why no box around the words has a transform.
It is a button with role switch and aria-checked: Enter and Space turn it on and off, and its name is the words next to it (aria-labelledby).
| Name | File | Default | What it changes |
|---|---|---|---|
TIME | script.js | 0.85 | The seconds of the change, day to night and back. |
STRETCH | script.js | 1.18 | How much the sun stretches as it slides. |
RAYS | script.js | 8 | The sun’s rays. |
PEEK | script.js | 4 | How far the sun peeks under the mouse, in pixels. |
To choose between the light and the dark theme of a site or an app, when the change can be a little show too. On a real site the choice should be saved, and the first time it can start from the system’s (prefers-color-scheme).
The switch gets a little smaller below 420 pixels and taps work like clicks; the circle of the night always starts from the switch and covers the whole screen.
No slide and no circle: the switch changes at once and the night covers the page, or leaves it, in a fade of a quarter of a second.
GSAP 3.15.0, Nunito (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 5.1 KB; the libraries: GSAP 28 KB.
Tested on 12 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.
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.