Skip to content
animorio
IT
All components

Pair headphones button

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

A dark button that pairs headphones over Bluetooth: pressed, blue waves leave the Bluetooth sign and cross the pill while a stroke of light runs along the sign and the label turns to Searching. When the headphones answer, blue floods the button from the sign, the label rolls up to the headphones’ name and on the right a chip opens on a spring with the headphones and a battery that fills up to 82%. Pressed again, it lets them go.

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>
<!--
  "Pair headphones 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>The pair headphones button with Bluetooth waves and a battery that fills</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">
    <!-- a pairing button: pressed, rings leave the Bluetooth sign and cross the pill while it searches; when the
         headphones answer, their chip lands on the right on a spring, the pill floods with blue from the sign, the
         label rolls to the device name and the small battery fills up to its level; pressed again it lets go -->
    <button class="pair" type="button" aria-pressed="false" data-pair>
      <span class="pair__body" aria-hidden="true">
        <span class="pair__flood" data-flood></span>
        <svg class="pair__rings" data-rings-box>
          <circle data-ring r="10"></circle>
          <circle data-ring r="10"></circle>
          <circle data-ring r="10"></circle>
        </svg>
        <span class="pair__light"></span>
      </span>
      <span class="pair__edge" aria-hidden="true"></span>

      <span class="sign" data-sign aria-hidden="true">
        <svg viewBox="0 0 24 24">
          <path class="sign__base" d="M7.2 7.4 16.6 16.2 12 20.6V3.4L16.6 7.8 7.2 16.6"></path>
          <path class="sign__lit" data-sign-lit pathLength="100" d="M7.2 7.4 16.6 16.2 12 20.6V3.4L16.6 7.8 7.2 16.6"></path>
        </svg>
      </span>

      <span class="label"><span class="label__word" data-word>Pair headphones</span></span>

      <span class="device" data-device aria-hidden="true">
        <svg class="device__phones" viewBox="0 0 24 24">
          <path d="M5 14.5V12a7 7 0 0 1 14 0v2.5"></path>
          <rect x="3.6" y="13.4" width="4" height="6.4" rx="1.8"></rect>
          <rect x="16.4" y="13.4" width="4" height="6.4" rx="1.8"></rect>
        </svg>
        <span class="battery">
          <span class="battery__cell"><span class="battery__level" data-level></span></span>
          <span class="battery__tip"></span>
        </span>
        <span class="device__pct" data-pct>0%</span>
      </span>
    </button>
    <p class="sr" data-live aria-live="polite"></p>

    <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>

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.

16 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 “Pair headphones 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

On black, a dark pill 60 pixels tall with an edge that catches light from above: on the left the Bluetooth sign in its round seat, then the label ‘Pair headphones’. On hover it lifts by a pixel and a soft light follows the pointer. Pressed, it gives and comes back on a spring; the label rolls up to ‘Searching…’, the sign dims a little and a blue stroke runs along its whole drawing, while three waves leave the middle of the sign, thin blue circles that widen and cross the pill to its right side, clipped by its shape. After two seconds the headphones answer: blue leaves the sign and floods the whole button, which swells by a breath and settles; the label rolls up to the name ‘Aria Pro’; on the right a darker chip opens on a spring with the drawn headphones, a small battery filling from the left and the percentage counting up to 82%, the level passing the mark by a hair and coming back. A blue glow stays under the button. Pressed again, the battery empties, the chip closes, the blue goes back into the sign and the label returns to ‘Pair headphones’. Left alone, a drawn pointer does the round by itself.

How it works

A pill in layers

The background, the flooding blue, the waves and the pointer light live in one layer with hidden overflow behind the content; the 1 pixel edge is a gradient cut out with a mask. That way the waves are clipped by the pill’s shape without clipping the shadow or the focus ring.

The waves from the sign

Three SVG circles centred on the sign (its position is measured with getBoundingClientRect, on resize too). A repeating timeline takes each radius from 14 pixels to the pill’s right side, offset by a third of the time, with the opacity rising fast and falling slowly.

The stroke that runs along the sign

Over the sign sits a blue copy of it with pathLength 100 and a 26 on 74 dash: moving stroke-dashoffset from 0 to 200 the stroke goes twice round the drawing while it searches.

The flooding blue

A 560 pixel circle centred on the sign at scale 0: on the answer it goes to 1 with power3.out and covers the pill from the left. The whole button takes a scale kick to 1.025 and comes back on an elastic spring.

The chip and the battery

The chip is measured once at its natural width (with ‘100%’ inside) and kept at width 0; on the answer the width goes to the measured value with elastic.out, so the label makes room on its own. One number animated from 0 to the charge writes the percentage and scales the battery’s level.

Values to change

NameFileDefaultWhat it changes
DEVICEscript.jsAria ProThe name of the headphones that answer.
BATTERYscript.js82The headphones’ charge, from 0 to 100.
ACCENTscript.js#3d7bffThe colour of the waves, the lit sign and the connected button.
SEARCHscript.js2.1How many seconds it searches before the headphones answer.
RINGscript.js1.25How many seconds a wave takes to cross the button.
SPRINGscript.js0.8How long the spring of the headphones’ chip lasts, in seconds.
HOLDscript.js2.8How many seconds it stays connected before the pointer lets go, when left alone.

Try them in the Playground

When to use it

For the settings of a music app or a system, for the page of a pair of headphones or a speaker, for any action that looks for a nearby device and then says it found it.

On phones

The same button, at most as wide as the screen minus the margins: the waves and the chip are measured again on the width. With a finger there is no hover: the touch does the press and the round.

With reduced motion

No waves and no springs: the labels, the blue and the chip change with a fade, the battery is already at its level.

Pitfalls

  • An SVG circle at opacity 0 with a round stroke is harmless, but the lit stroke of the sign at low opacity leaves a shadow: under 2% it is hidden with visibility.
  • A chip with automatic width cannot be animated: it is measured once with ‘100%’ inside, so the width does not change while the digits count.
  • The fromTo tweens placed later in the timeline applied their start value at once: they all have immediateRender: false.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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