
The layered button
Buttons, Hover, Physics
The vertical brightness slider of a control centre, on very light grey, in the style of one-gesture micro-interactions: a wide pill that fills from the bottom as you drag it, with inertia when flicked and a small elastic stretch past the ends. The sun at the bottom opens its rays one after another as it rises, the phone beside it really gets brighter and Night Shift warms the colours.
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 brightness slider" 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 brightness slider with a sun that opens its rays</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>
<!-- a control centre: drag the wide pill up and down, the screen beside it really gets brighter,
the sun opens its rays, and Night Shift warms the colour -->
<section class="set" data-card aria-label="Display brightness">
<figure class="screen" data-screen aria-hidden="true">
<div class="screen__glass">
<div class="app">
<div class="app__bar"><span class="app__logo"></span><span class="app__line w40"></span><span class="app__avatar"></span></div>
<div class="app__hero"><span class="app__sunset"></span><span class="app__hill"></span></div>
<p class="app__title">Evening, Noa</p>
<span class="app__line w70"></span>
<span class="app__line w50"></span>
<div class="app__chips"><span></span><span></span><span></span></div>
</div>
<div class="screen__warm" data-warm></div>
<div class="screen__dim" data-dim></div>
<div class="screen__shine"></div>
</div>
<span class="screen__notch"></span>
</figure>
<div class="panel" data-panel>
<div class="panel__head">
<p class="panel__label">Display</p>
<p class="panel__value" aria-hidden="true"><span class="digits" data-digits></span><span class="pct">%</span></p>
</div>
<div class="pill" data-pill role="slider" tabindex="0" aria-label="Brightness" aria-orientation="vertical" aria-valuemin="0" aria-valuemax="100" aria-valuenow="45">
<div class="pill__track" data-track>
<div class="pill__fill" data-fill><span class="pill__edge"></span></div>
</div>
<svg class="sun" data-sun viewBox="0 0 32 32" aria-hidden="true">
<circle class="sun__core" data-core cx="16" cy="16" r="4.6"></circle>
<g class="sun__rays" data-rays></g>
</svg>
</div>
<button class="night" type="button" data-night aria-pressed="false">
<svg viewBox="0 0 24 24" aria-hidden="true"><path class="night__moon" d="M15.6 4.4a7.6 7.6 0 1 0 4 11.9A6.2 6.2 0 0 1 15.6 4.4z"></path></svg>
<span class="night__text"><span class="night__name">Night Shift</span><span class="night__state" data-state>Off</span></span>
</button>
</div>
</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.
23 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 brightness slider” from Animorio and fit it into my siteOn touch the distance between the finger and the edge of the filled part is remembered (grabOff), so the brightness does not jump to the touched point but follows the finger from where it was. The value is the distance from the bottom of the track divided by its height, plus that distance.
While dragging, the speed is measured and blended with the previous one so it does not jitter. Let go, the pill carries on on the GSAP ticker with its speed dropping by e to the minus FRICTION times the time; past the ends a nearly critical spring (stiffness 260, damping 30) brings it back to the top or bottom.
Past the top or bottom the extra is squashed with a hyperbolic tangent, STRETCH times tanh of the excess in pixels over four STRETCH, and becomes a scaleY of the pill anchored on the opposite side.
Each ray is an SVG line that lengthens once the brightness passes its threshold, staggered round the circle; the sun follows the value a touch behind, so the rays open softly. The screen has a black veil on top with opacity (1 minus the value) times DARKEST, and Night Shift an orange veil in multiply.
| Name | File | Default | What it changes |
|---|---|---|---|
START | script.js | 45 | The starting brightness, from 0 to 100. |
FRICTION | script.js | 7 | How quickly a flicked pill stops: higher stops sooner. |
STRETCH | script.js | 14 | How many pixels at most the pill stretches when pulled past the ends. |
DARKEST | script.js | 0.82 | How dark the screen gets at zero brightness, from 0 to 1. |
WARMTH | script.js | 0.34 | How much Night Shift warms the colours, from 0 to 1. |
RAYS | script.js | 8 | How many rays the sun has. |
STEP | script.js | 5 | How much the arrow keys move the brightness. |
In the control centre of an app or a system, in a display settings panel, in the control of home lights or a smart lamp: anywhere a quantity is set with a single gesture and the result should show right beside it.
Phone and panel are sized on the window height (the min of 64vh, 340 pixels and 92vw), so they sit side by side even in the short phone box. With a finger the pill drags and flicks as with the mouse, without scrolling the page.
No inertia, elastic or jolts: the pill follows the finger and stops where it is let go, the digits change without rolling, the Night Shift colours fade in and the autopilot shows the values one after another.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 7.7 KB; the libraries: GSAP 28 KB.
Tested on 28 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.