Skip to content
animorio
IT
All components

Smart plug button

Buttons, Hover, SVGGSAP, CSS onlyMediumCompressed weight: Demo 7.4 KBGSAP 28 KBFreeDownload the zip

The power button of a smart plug in a home app: the Studio «Desk lamp» card, with a European Schuko plug drawn in profile: two round metal pins, a ribbed grip and a strain relief that bends with the cable. Press it and the round button sinks and springs back, the plug runs to the wall and clicks in, the cable pulls straight and settles, the amber ring draws itself around the button and the watts roll from 0.0 to 42.6, then drift gently like a real meter. Press again and the plug comes out with a little tug and the watts fall back to zero. On black, with a single amber accent.

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>
<!--
  "Smart plug button" 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>Smart plug button</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/inter@5.3.0/index.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/jetbrains-mono@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- a smart plug in a home app: press the power button, the plug clicks into the wall and the watts roll up -->
    <section class="card" data-card aria-label="Smart plug">
      <header class="head">
        <div class="head__text">
          <span class="room">Studio</span>
          <span class="name">Desk lamp</span>
        </div>
        <span class="state" aria-hidden="true"><span class="state__roll" data-state><span>Off</span><span>On</span></span></span>
      </header>

      <div class="scene" aria-hidden="true">
        <svg class="scene__svg" viewBox="0 0 240 80" data-scene>
          <defs>
            <!-- matte plastic: light from above, a soft core, darker underside -->
            <linearGradient id="plastica" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#3b3c43" />
              <stop offset=".22" stop-color="#2d2e34" />
              <stop offset=".62" stop-color="#222328" />
              <stop offset="1" stop-color="#17181c" />
            </linearGradient>
            <linearGradient id="faccia" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#44454c" />
              <stop offset=".3" stop-color="#33343a" />
              <stop offset="1" stop-color="#1b1c20" />
            </linearGradient>
            <linearGradient id="costola" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#4a4b52" />
              <stop offset=".35" stop-color="#34353b" />
              <stop offset="1" stop-color="#1e1f23" />
            </linearGradient>
            <linearGradient id="guaina" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#36373d" />
              <stop offset=".5" stop-color="#26272c" />
              <stop offset="1" stop-color="#18191d" />
            </linearGradient>
            <!-- a round brass-nickel pin: bright line near the top, dark belly -->
            <linearGradient id="spinotto" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#7d7f86" />
              <stop offset=".28" stop-color="#eeeef0" />
              <stop offset=".5" stop-color="#b9bac0" />
              <stop offset=".82" stop-color="#5d5f66" />
              <stop offset="1" stop-color="#3c3d43" />
            </linearGradient>
            <linearGradient id="placca" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#24252a" />
              <stop offset=".5" stop-color="#1c1d21" />
              <stop offset="1" stop-color="#141518" />
            </linearGradient>
            <linearGradient id="smusso" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#3c3d44" />
              <stop offset=".5" stop-color="#2a2b31" />
              <stop offset="1" stop-color="#18191c" />
            </linearGradient>
            <linearGradient id="incasso" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#060608" />
              <stop offset=".75" stop-color="#0d0e11" />
              <stop offset="1" stop-color="#17181c" />
            </linearGradient>
            <linearGradient id="ombra" x1="0" y1="0" x2="1" y2="0">
              <stop offset="0" stop-color="#000" stop-opacity=".75" />
              <stop offset="1" stop-color="#000" stop-opacity="0" />
            </linearGradient>
            <linearGradient id="muro" x1="0" y1="0" x2="0" y2="1">
              <stop offset="0" stop-color="#2c2d33" stop-opacity="0" />
              <stop offset=".5" stop-color="#3a3b42" />
              <stop offset="1" stop-color="#2c2d33" stop-opacity="0" />
            </linearGradient>
          </defs>
          <path class="cable" data-cable d="M -4 52 C 40 70 80 70 102 40" />
          <path class="cable__shine" data-cable-shine d="M -4 52 C 40 70 80 70 102 40" />
          <g data-plug>
            <!-- two round pins, chamfered tips; they slide behind the wall plate when the plug is in -->
            <path class="prong" d="M 149 31.8 L 165.4 31.8 Q 167.4 31.8 167.8 33.2 L 167.8 34.8 Q 167.4 36.2 165.4 36.2 L 149 36.2 Z" />
            <path class="prong" d="M 149 43.8 L 165.4 43.8 Q 167.4 43.8 167.8 45.2 L 167.8 46.8 Q 167.4 48.2 165.4 48.2 L 149 48.2 Z" />
            <!-- strain relief: the sleeve narrows towards the cable and bends with it -->
            <g data-sleeve>
              <path class="sleeve" d="M 119 33.6 C 113 34.4 107 36.6 102.6 37.8 C 101.4 38.1 101.4 41.9 102.6 42.2 C 107 43.4 113 45.6 119 46.4 Z" />
              <path class="sleeve__ring" d="M 107.5 36.4 C 107.9 38.6 107.9 41.4 107.5 43.6" />
              <path class="sleeve__ring" d="M 111.6 35.3 C 112.1 38.2 112.1 41.8 111.6 44.7" />
              <path class="sleeve__ring" d="M 115.4 34.4 C 116 37.9 116 42.1 115.4 45.6" />
            </g>
            <!-- body: rounded back, a grip that narrows a little, then flares into the round front face -->
            <path class="plug" d="M 118 32.4 C 118 30.2 119.2 29.2 121.6 29 L 128 29.8 C 134 30.2 138.6 28.8 141 26.8 C 142.6 25.4 144 24.6 146 24.6 L 147.6 24.6 C 149 24.6 149.6 25.6 149.6 27.2 L 149.6 52.8 C 149.6 54.4 149 55.4 147.6 55.4 L 146 55.4 C 144 55.4 142.6 54.6 141 53.2 C 138.6 51.2 134 49.8 128 50.2 L 121.6 51 C 119.2 50.8 118 49.8 118 47.6 Z" />
            <!-- the front face, a shade lighter, with its rim catching the light -->
            <path class="plug__face" d="M 144.8 25.2 C 145.4 24.8 146 24.6 147 24.6 L 147.6 24.6 C 149 24.6 149.6 25.6 149.6 27.2 L 149.6 52.8 C 149.6 54.4 149 55.4 147.6 55.4 L 147 55.4 C 146 55.4 145.4 55.2 144.8 54.8 Z" />
            <path class="plug__rim" d="M 145.2 25.4 C 146 24.9 146.8 24.8 147.6 24.8 C 148.8 24.8 149.3 25.7 149.3 27" />
            <!-- the earthing clips on the top and bottom of the face -->
            <rect class="plug__clip" x="145.6" y="23.9" width="3.2" height="1.1" rx=".5" />
            <rect class="plug__clip" x="145.6" y="55" width="3.2" height="1.1" rx=".5" />
            <!-- mould parting line along the body -->
            <path class="plug__seam" d="M 120.4 40.2 L 143.6 40.2" />
            <!-- grip ribs: raised rings with a dark groove between them -->
            <g class="plug__ribs">
              <path class="rib__groove" d="M 124.6 30.1 L 124.6 49.9" />
              <path class="rib" d="M 125.2 29.4 L 126.8 29.5 L 126.8 50.5 L 125.2 50.6 Z" />
              <path class="rib__groove" d="M 128.6 30 L 128.6 50" />
              <path class="rib" d="M 129.2 29.5 L 130.8 29.6 L 130.8 50.4 L 129.2 50.5 Z" />
              <path class="rib__groove" d="M 132.6 29.9 L 132.6 50.1" />
              <path class="rib" d="M 133.2 29.4 L 134.8 29.2 L 134.8 50.8 L 133.2 50.6 Z" />
              <path class="rib__groove" d="M 136.6 29.3 L 136.6 50.7" />
            </g>
            <!-- soft light along the top edge of the plastic -->
            <path class="plug__shine" d="M 120 30 C 122 29.4 126 29.9 128 30.1 C 133.4 30.4 137.4 29.4 140 27.6" />
          </g>
          <g class="wall" data-wall>
            <!-- shadow of the plug on the plate, darker as it gets close -->
            <rect class="wall__plate" x="199" y="8" width="17" height="64" />
            <path class="wall__bevel" d="M 196 12 L 199 8 L 199 72 L 196 68 Z" />
            <!-- the recessed socket the pins disappear into -->
            <rect class="wall__socket" x="196" y="23.4" width="3.4" height="33.2" rx="1" />
            <path class="wall__lip" d="M 196.3 56.4 L 199.2 56.4" />
            <rect class="wall__shadow" data-shadow x="196" y="20" width="12" height="40" opacity="0" />
            <line class="wall__edge" x1="216.5" y1="0" x2="216.5" y2="80" stroke="url(#muro)" />
          </g>
        </svg>
      </div>

      <div class="power">
        <div class="power__hold" data-hold>
          <svg class="ring" viewBox="0 0 100 100" aria-hidden="true">
            <circle class="ring__track" cx="50" cy="50" r="47" />
            <circle class="ring__fill" data-ring cx="50" cy="50" r="47" pathLength="1" />
          </svg>
          <button class="btn" type="button" data-btn aria-pressed="false" aria-label="Desk lamp power">
            <span class="btn__shine" aria-hidden="true"></span>
            <svg class="btn__icon" viewBox="0 0 24 24" aria-hidden="true" data-icon>
              <path d="M7.05 7.72a7 7 0 1 0 9.9 0" />
              <path d="M12 4.33v8.2" />
            </svg>
          </button>
        </div>
        <div class="watts" aria-live="polite">
          <span class="sr" data-sr>0.0 watts</span>
          <span class="watts__num" aria-hidden="true">
            <span class="col" data-col="0"></span><span class="col" data-col="1"></span><span class="dot">.</span><span class="col" data-col="2"></span>
          </span>
          <span class="watts__unit" aria-hidden="true">W</span>
        </div>
        <span class="hint" data-hint>Today 0.31 kWh</span>
      </div>
    </section>
  </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.

25 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Smart plug button” 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

A dark card with «Studio» and «Desk lamp», the Off state pill, the side-on scene with the plug on its cable and the socket in the wall, the round button with the power icon and below it the watts pill, 0.0 W. Hover it and the button lifts a pixel while its highlight brightens; press it and it sinks to 0.94 and springs back. On click the plug runs to the wall, goes a hair too far and settles, the cable pulls straight and then relaxes a touch, the socket shivers by a pixel; the amber ring draws itself around the button, the icon turns amber, Off rolls into On and the watts climb to 42.6 one digit at a time, then drift gently. On the second click the plug comes out with a little tug, the cable falls back, the ring empties the same way round and the watts drop back to 0.0.

How it works

The cable is a single curve

The cord is an SVG path with one Bézier curve: an object holding the plug position and how much the cable hangs is animated by GSAP, and on every frame the path’s d attribute and the plug’s offset are rewritten.

The click

The plug arrives with power3.in slightly past its spot and comes back with a short elastic.out: that settle is what makes the click feel real. At the same moment the socket shifts by 0.8 units and returns.

The ring

The circle has pathLength 1: switching on takes stroke-dashoffset from 1 to 0; switching off from 0 to -1, so it empties the same way round it filled.

The watts

Every digit is a column with 0 to 9 stacked, and the reading moves each column onto its digit with yPercent, one after the other, with a back.out.

The centre

The button and the ring share the same square cell, centred with place-items; the ring is an absolute SVG that fills the cell, rotated by -90 degrees around its own centre.

Values to change

NameFileDefaultWhat it changes
WATTSscript.js42.6The watts the lamp draws once it is on.
WOBBLEscript.js0.8How many watts the reading drifts up and down while it is on.
PRESSscript.js0.94Scale of the button while pressed.
SNAPscript.js0.55Seconds the plug takes to click into the wall.
SAGscript.js18How much the cable hangs when the plug is out.
ROLLscript.js0.07Seconds between one digit of the watts and the next.
AUTO_PAUSEscript.js5Seconds of quiet before the demo plays by itself again.

Try them in the Playground

When to use it

In a smart home app, on the panel of a plug or a light, in an energy dashboard: wherever switching something on should show straight away what came on and how much it draws.

On phones

Everything is in em and the size depends on both the width and the height of the window, so the card fits the phone box. A tap works like a click; hover only exists where there is a mouse.

With reduced motion

No springs or movement: the plug fades out and back in at its new spot, the ring appears already whole, the colour fades and the watts change without rolling.

Pitfalls

  • The ring around the button is rotated by -90 degrees on the whole svg with a CSS transform: its centre is the cell’s, never svgOrigin on the svg.
  • With stroke-dashoffset and pathLength 1 autoRound has to be off, or the ring pops in at once.
  • The digit columns sit in a container with hidden overflow: its height has to be exactly one line, or the next digit shows halfway.
  • The drifting reading is a timeline with repeat: -1: it has to be killed when switching off.

Libraries

GSAP 3.15.0, Inter (font variabile) 5.3.0, JetBrains Mono (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 7.4 KB; the libraries: GSAP 28 KB.

Testing

Tested on 28 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