
The layered button
Buttons, Hover, Physics
The Back lawn sprinklers card of Loam, a made-up app for the home garden, and the switch is a glass pipe as long as the card with a glazed ceramic knob. On, the knob runs on a spring to the far end and squashes a hair against the cap, and behind it the water rushes into the pipe with its front bulging as it runs, then keeps flowing with the streaks of the current, the air bubbles and the wave on top. The line under the title becomes Watering, the sprinkler in the icon sprays and swings, and under the pipe the time left counts down, the flow climbs to 8.4 litres a minute and the litres used add up, digit by digit. Off, the knob springs back and the pipe drains, leaving a few drops on the glass that slide and dry.
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>
<!--
"Sprinkler toggle switch" 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 garden sprinklers toggle switch with the water that flows through the track</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">
<!-- one gesture: turn the sprinklers on. The track of the switch is a glass pipe; the ceramic knob runs along it
on a spring and the water rushes in behind it, bulging at the front, then keeps flowing with its streaks and
bubbles. The label, the sprinkler head and the small readings under the pipe say it too: the time left
counts down, the flow climbs, the litres add up. Off, the knob springs back and the pipe drains -->
<div class="wrap" data-wrap>
<section class="card" data-card aria-labelledby="ir-title">
<i class="card__glow" data-glow aria-hidden="true"></i>
<i class="card__edge" data-edge aria-hidden="true"></i>
<i class="card__grain" aria-hidden="true"></i>
<header class="head">
<span class="tile" data-tile aria-hidden="true">
<svg class="tile__svg" viewBox="0 0 32 32">
<g class="tile__spray" data-spray>
<path class="tile__jet" d="M16 13.2C13 9.6 9.2 7.6 4.6 7.2"></path>
<path class="tile__jet" d="M16 13.2C16 8.8 16 6 16 3.4"></path>
<path class="tile__jet" d="M16 13.2C19 9.6 22.8 7.6 27.4 7.2"></path>
</g>
<g class="tile__head" data-nozzle>
<rect x="13.6" y="12.4" width="4.8" height="3.4" rx="1.2"></rect>
</g>
<path class="tile__body" d="M11.4 16.4h9.2l-.9 7.4a1.6 1.6 0 0 1-1.6 1.4h-4.2a1.6 1.6 0 0 1-1.6-1.4Z"></path>
<path class="tile__lawn" d="M5 26.6h22"></path>
</svg>
</span>
<div class="head__copy">
<h2 class="head__title" id="ir-title">Back lawn sprinklers</h2>
<p class="head__sub">
<span class="roll" data-sub>
<span class="roll__face" data-sub-off>Off · next run tomorrow, 6:00</span>
<span class="roll__face roll__face--on" data-sub-on aria-hidden="true">Watering · rotor heads open</span>
</span>
</p>
</div>
</header>
<button class="pipe" type="button" role="switch" aria-checked="false" aria-labelledby="ir-title" data-switch data-autoclic>
<span class="pipe__glass" aria-hidden="true">
<svg class="pipe__svg" data-svg>
<defs>
<linearGradient id="ir-water" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="var(--water-top)"></stop>
<stop offset="0.45" stop-color="var(--water)"></stop>
<stop offset="1" stop-color="var(--water-deep)"></stop>
</linearGradient>
<clipPath id="ir-pipe"><rect data-pipeclip></rect></clipPath>
<clipPath id="ir-wet"><path data-wetclip></path></clipPath>
</defs>
<g clip-path="url(#ir-pipe)">
<path class="water" data-water fill="url(#ir-water)"></path>
<g clip-path="url(#ir-wet)">
<g data-streaks></g>
<g data-bubbles></g>
</g>
<path class="water__front" data-front></path>
<g data-drops></g>
</g>
</svg>
<span class="pipe__shine"></span>
</span>
<span class="pipe__word pipe__word--off" data-word-off aria-hidden="true">Off</span>
<span class="pipe__word pipe__word--on" data-word-on aria-hidden="true">On</span>
<span class="knob" data-knob aria-hidden="true">
<span class="knob__body" data-knobbody>
<span class="knob__ceramic"></span>
<svg class="knob__drop" viewBox="0 0 20 20"><path data-dropicon d="M10 3.2c2.6 3.2 4.6 5.8 4.6 8.4a4.6 4.6 0 0 1-9.2 0c0-2.6 2-5.2 4.6-8.4Z"></path><path class="knob__glint" d="M8 12.6a2.2 2.2 0 0 0 1.6 1.9"></path></svg>
</span>
</span>
</button>
<dl class="meta">
<div class="meta__cell">
<dt>Time left</dt>
<dd><span class="num" data-time>12:00</span></dd>
</div>
<div class="meta__cell">
<dt>Flow</dt>
<dd><span class="num" data-flow>0.0</span><small>L/min</small></dd>
</div>
<div class="meta__cell">
<dt>Used</dt>
<dd><span class="num" data-used>0.0</span><small>L</small></dd>
</div>
</dl>
</section>
</div>
<p class="sr" aria-live="polite" data-live></p>
</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 “Sprinkler toggle switch” from Animorio and fit it into my siteThe knob's position is not a tween: it is a spring integrated on every frame of the GSAP ticker (stiffness 260, damping 27), which lands one pixel too far. Whatever goes past the cap becomes a squash of the knob, and its speed stretches it a little as it runs.
The water is an SVG path rebuilt by the ticker: the surface is a sum of two travelling sine waves, the front is a Bézier curve that bulges with the front's speed, and everything is cut to the pipe's shape by a clipPath. Front and level have two springs softer than the knob's, so the water runs after it.
The light streaks and the bubbles are SVG lines and circles cut by a second clipPath holding the same path as the water: they ride to the right at different speeds and start again from the left, and their opacity follows the level, so they fade as the pipe drains.
Each number under the pipe is made of windows, one per character: when a digit changes, the old one leaves at the top and the new one comes in from below with the same power3.inOut, so they never overlap. The flow updates every 200 milliseconds, so the climb reads instead of flickering.
| Name | File | Default | What it changes |
|---|---|---|---|
RUN_MIN | script.js | 12 | The minutes of one watering run, the time that counts down. |
FLOW | script.js | 8.4 | The litres a minute that go through the pipe. |
SPRING | script.js | 260 | The stiffness of the knob's spring. |
DAMPING | script.js | 27 | The spring's damping: lower, the more the knob bounces. |
RUSH | script.js | 0.55 | How fast the water runs after the knob. |
STREAM | script.js | 70 | The speed of the current, in pixels a second. |
BUBBLES | script.js | 7 | How many air bubbles ride in the water. |
LEVEL | script.js | 0.72 | How full the pipe is while the water flows. |
--water | style.css | #2f8ff0 | The colour of the water, the one accent. |
--glass | style.css | #eef0f2 | The colour of the empty pipe. |
In a smart home or irrigation app, in the settings of a garden, a greenhouse or a shared vegetable patch: a switch that says at once what is happening and for how long, with the time left and the water used next to it.
The card narrows to 90% of the width and the pipe drops to 46 pixels tall on short screens; the finger taps like the mouse and the knob widens under it. Without hover the knob does not lean.
No running knob and no rushing water: the knob fades out and back in at the other end, the water fades in already still in the pipe and the line changes with a fade; the readings keep counting, without rolling.
GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.
Compressed with gzip, the three demo files weigh 11 KB; the libraries: GSAP 28 KB.
Tested on 16 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.