Skip to content
animorio
IT
All components

Add protection button

Buttons, HoverGSAP, CSS onlyMediumCompressed weight: Demo 9.0 KBGSAP 28 KBFreeDownload the zip

The protection line in the cart of an invented premium audio store, Halden Audio: a graphite glass button 60 pixels tall with a real photo of the headphones in its round end and a small empty shield on the corner. Tapped, the title shimmers while a mint ring winds round the photo and closes; then the shield fills and seals with a check, a sheen crosses the glass, the price leaves the chip and falls into the total, the total rolls up on drums and the Covered to Nov 2028 tag comes out from under the button. On the sealed button the chip turns into Remove: tapped, the ring unwinds, the shield empties, the tag tucks back and the total rolls down.

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>
<!--
  "Add protection 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 Add protection button with the seal that closes the shield</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">
    <!-- the protection plan line of a premium audio store cart (Halden Audio): one graphite glass button with the
         photo of the headphones in its round end. Tapped, a ring closes around the photo, the shield on its corner
         fills and seals with a check, the price drops into the total, the total rolls up on drums and the coverage
         tag comes out from under the button. Tapped again (Remove), everything goes back. -->
    <div class="cover" data-cover>
      <button class="add" type="button" data-add aria-pressed="false">
        <span class="add__glow" aria-hidden="true"></span>
        <span class="add__shine" data-shine aria-hidden="true"></span>
        <span class="thumb" data-thumb>
          <svg class="thumb__ring" viewBox="0 0 56 56" aria-hidden="true">
            <circle class="thumb__track" cx="28" cy="28" r="26"/>
            <circle class="thumb__arc" data-ring cx="28" cy="28" r="26" pathLength="1"/>
          </svg>
          <span class="thumb__photo" data-photo>
            <img src="cuffie.webp" alt="Black over-ear headphones" width="240" height="240" decoding="async">
          </span>
          <span class="badge" data-badge aria-hidden="true">
            <svg class="badge__svg" viewBox="0 0 22 24">
              <path class="badge__base" d="M11 1.6l7.6 3v5.9c0 5.1-3.2 9.3-7.6 11.3-4.4-2-7.6-6.2-7.6-11.3V4.6z"/>
              <path class="badge__fill" data-fill d="M11 1.6l7.6 3v5.9c0 5.1-3.2 9.3-7.6 11.3-4.4-2-7.6-6.2-7.6-11.3V4.6z"/>
              <path class="badge__edge" data-edge pathLength="1" d="M11 1.6l7.6 3v5.9c0 5.1-3.2 9.3-7.6 11.3-4.4-2-7.6-6.2-7.6-11.3V4.6z"/>
              <path class="badge__plus" data-plus d="M11 8.2v6.4M7.8 11.4h6.4"/>
              <path class="badge__check" data-check pathLength="1" d="M7.4 11.8l2.6 2.6 4.6-5.2"/>
            </svg>
          </span>
        </span>
        <span class="add__text">
          <span class="add__title"><span class="add__words" data-title>Add 2-year protection</span></span>
          <span class="add__sub"><span class="add__words" data-sub>Halden Care · drops and spills</span></span>
        </span>
        <span class="chip" data-chip>
          <span class="chip__face"><span class="chip__words" data-chip-words>+$29</span></span>
        </span>
      </button>
      <div class="sum" data-sum>
        <span class="sum__left">
          <span class="sum__label">Total</span>
          <span class="tag-slot">
            <span class="tag" data-tag aria-hidden="true">
              <svg class="tag__icon" viewBox="0 0 22 24"><path d="M11 1.6l7.6 3v5.9c0 5.1-3.2 9.3-7.6 11.3-4.4-2-7.6-6.2-7.6-11.3V4.6z"/><path class="tag__tick" d="M7.4 11.8l2.6 2.6 4.6-5.2"/></svg>
              <span data-tag-words>Covered to Nov 2028</span>
            </span>
          </span>
        </span>
        <span class="odo" data-odo></span>
      </div>
      <span class="ghost" data-ghost aria-hidden="true">+$29</span>
    </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.

23 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 “Add protection 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 a black page a graphite glass pill button rises on a spring, with a 1 pixel edge that catches the light, a light line along the top and a fine grain. In the round end on the left there is the photo of the black headphones in a circle, with a small silver shield with a plus on its corner; beside it ‘Add 2-year protection’ and, smaller, ‘Halden Care · drops and spills’; on the right the ‘+$29’ chip. Below, after a thin line, ‘Total’ and $349.00. Hovered, a soft light follows the pointer, the edge brightens, the shield tilts and the chip lifts by a pixel. Tapped, the button gives and comes back on a spring, the title turns into a shimmering ‘Activating cover’, and a mint arc runs round the photo, growing until the ring closes. Then the shield gives a small jump, fills with mint, its edge draws itself and a check appears inside; the photo jolts, a sheen crosses the glass and a mint light comes up on the left. The title becomes ‘Protected for 2 years’, the price leaves the chip and drops in an arc into the total, which rolls up on drums from right to left to $378.00 and turns mint for a moment; the chip says ‘Added’, and from under the button the ‘Covered to Nov 2028’ tag comes out with a slight turn. Hovered, the chip becomes ‘Remove’: tapped, the check rubs out, the shield empties and the plus comes back, the ring unwinds backwards, the tag tucks back under the button and the total rolls down while ‘−$29’ rises back to the chip.

How it works

Glass without blur

The button uses no backdrop-filter: it is a graphite top to bottom gradient, a 1 px edge and an inner line of light made with inset box-shadows, a faded light line in an ::after and feTurbulence grain in an SVG background, in overlay at 14%. Two CSS variables, --lit and --halo, light a mint glow on the left and the halo underneath while the cover is on, animated by GSAP.

The ring that winds

The ring is a circle with pathLength 1: on each update of a single tween (p from 0 to 1) the script writes the stroke-dasharray, with an arc that grows as p to the power of 2.1, and a transform attribute that spins it by 450 degrees. So it starts as a short running arc that slows down as it closes; to remove the cover the same tween goes back to 0 and the ring unwinds backwards.

The shield that seals

The shield is the same path three times: the dark base, the mint fill fading in and the light edge with pathLength 1 drawn by animating the stroke-dashoffset attribute (not the CSS property, which would cover it). The plus turns and leaves, the check draws itself the same way, and the shield arrives from a scale of 1.32 on a spring.

The total on drums

Price and total are written with two decimals and aligned to the right; each digit is a drum with two rounds of eleven places (blank and ten digits). Adding, the drum goes to the second round, removing it goes back to the first: so it rolls up and down in two different directions, and digits that stay the same do not move. A blank drum is zero wide, and widens if the total gains a digit.

A real spring as an ease

The press, the shield, the tag and the drums use a hand written ease function: the response of a damped spring (BOUNCE) normalised between 0 and 1, which passes the mark by a pixel and settles. The tweens inside the timelines have immediateRender: false, otherwise the words meant to come in later would vanish at once.

Values to change

NameFileDefaultWhat it changes
PRICEscript.js349The price of the headphones already in the cart, in dollars: the starting total.
COVERscript.js29The price of the protection, shown on the chip and added to the total.
YEARSscript.js2The years of cover: they change the title and the date on the tag.
WORKscript.js1.1The seconds the ring takes to wind round the photo before the seal.
BOUNCEscript.js0.72The springs: lower bounces more (0.5), higher settles without passing the mark (1).
HOLDscript.js2.8The seconds the pilot waits on the sealed button before tapping Remove.
LOOPscript.jstrueThe pilot adds and removes the cover again and again.

Try them in the Playground

When to use it

In the cart or at the checkout of an online store for electronics, audio, phones, bikes or furniture that sells an extended warranty or a protection plan; it fits any optional add-on that changes the total (shipping insurance, assembly, a premium service) and add-on plans in subscription apps.

On phones

The same animation with adapted sizes: the button is 92% of the screen wide (at most 372 pixels) and stays 60 tall, the words shrink with clamp, the chip gets shorter under 360 pixels; a second tap removes the cover, so Remove works by touch too.

With reduced motion

Nothing moves: the button fades in, the ring closes at once, the shield fills with a fade and no jump, the words change in place, the price does not fly, the total changes without drums and the tag fades in; the shimmering title stays still and grey.

Pitfalls

  • A fromTo inside a timeline draws its starting state at once: the subtitle and the chip vanished as soon as the loading began. Every fromTo that starts later has immediateRender: false.
  • With the stroke-dashoffset written in the CSS the attribute animation did not show: the CSS property wins over the attribute. The dashes of the ring, edge and check live only in attributes.
  • With a zero length arc and round caps, a mint dot stayed at the top of the ring at rest: below a small value the stroke has stroke-opacity 0.
  • With Mona Sans tabular-nums gives a slashed zero: the digits of the total sit in drums 0.6 em wide and centred, without tnum.
  • The flying price and the word Added in the same chip overlapped: first the price leaves, then Added comes in.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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