Skip to content
animorio
IT
All components

Sprinkler toggle switch

Toggles, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

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.

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>
<!--
  "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&nbsp;·&nbsp;next run tomorrow, 6:00</span>
                <span class="roll__face roll__face--on" data-sub-on aria-hidden="true">Watering&nbsp;·&nbsp;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>

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 “Sprinkler toggle switch” 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 a white ground sits the white card with its one-pixel edge and soft shadows: at the top the tile with the sprinkler drawn in line, the title Back lawn sprinklers and the grey line Off · next run tomorrow, 6:00; below, across the whole card, the empty glass pipe with the ceramic knob on the left, the engraved drop and the word OFF; at the bottom the three readings at rest, Time left 12:00, Flow 0.0 L/min, Used 0.0 L. On hover the knob leans three pixels towards the other end and the glass takes a hint of blue; pressed, it widens like a pushing finger. On the tap the knob runs on a spring to the far end, squashes against the cap and settles, and a moment later the water rushes in from the left: a round front that bulges more the faster it runs, the surface rippling, then the light streaks of the current and the bubbles riding to the right. The drop on the knob fills with blue with a small elastic, under the title the line rolls to Watering · rotor heads open, the sprinkler sprays its three dotted jets and swings back and forth, the card takes a cool light from under the pipe and the readings light up: the time goes down a second at a time, the flow climbs to 8.4 and the litres add up, every digit that changes rolling in its own window. Another tap brings the knob back; the pipe drains with the level falling and the wave sloshing, and six drops stay on the glass, wait, slide down and dry.

How it works

The knob on a real spring

The 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 drawn on every frame

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 current inside the water

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.

The digits that roll one by one

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.

Values to change

NameFileDefaultWhat it changes
RUN_MINscript.js12The minutes of one watering run, the time that counts down.
FLOWscript.js8.4The litres a minute that go through the pipe.
SPRINGscript.js260The stiffness of the knob's spring.
DAMPINGscript.js27The spring's damping: lower, the more the knob bounces.
RUSHscript.js0.55How fast the water runs after the knob.
STREAMscript.js70The speed of the current, in pixels a second.
BUBBLESscript.js7How many air bubbles ride in the water.
LEVELscript.js0.72How full the pipe is while the water flows.
--waterstyle.css#2f8ff0The colour of the water, the one accent.
--glassstyle.css#eef0f2The colour of the empty pipe.

Try them in the Playground

When to use it

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.

On phones

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.

With reduced motion

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.

Pitfalls

  • The card with overflow: hidden and the absolute light sticking out below is a scroll container: the click focused the pipe and the browser scrolled the card up, with the title out of view. With overflow: clip it no longer scrolls.
  • The Watering line started hidden with a translateY in the CSS: GSAP read it in pixels and kept it under the yPercent, so the line never came back. GSAP sets the starting position.
  • The rolling digits overlapped into a smudge: the old one left with power2.in and the new one came in with a back.out, faster at the start. With the same curve for both and only one old digit per window they never touch.
  • Turning off, the water front chased the knob and the pipe looked sucked to the left: now the front stays still and the level falls, like a draining pipe, and the front only goes back once the pipe is empty.
  • The knob is moved by the ticker: the press is a tweened number that the ticker reads and writes on the body together with the squash against the cap, or every frame wiped out GSAP's scale.

Libraries

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.

Testing

Tested on 16 November 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