Skip to content
animorio
IT
All components

Hold to approve agent

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

An AI assistant asks permission before acting, on an almost black background, in the style of the light effects of AI apps: «Halcy wants to send 3 emails to the design team» and below it the dark pill Hold to approve. A single gesture, press and hold: a cold light charges along the pill’s border from the top, with a white head and a soft halo, while the button squashes and then swells slightly; let go early and the light runs back and the pill bounces on a spring. When it reaches the end the light closes the loop, a flash runs once all the way round, the shield turns green with a drawn check and the label rolls to Approved.

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>
<!--
  "Hold to approve agent" 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 hold to approve button for an AI agent</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">
    <!-- an AI agent asks before acting: hold the button and a beam of light charges along its border; let go early and it
         springs back, hold to the end and the beam closes, flashes round once and the label rolls to Approved -->
    <section class="ask" data-ask aria-label="Agent approval">
      <p class="ask__who">
        <svg class="ask__mark" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 2.2c.5 3.9 2.1 5.4 5.9 5.9-3.8.5-5.4 2.1-5.9 5.9-.5-3.8-2-5.4-5.9-5.9 3.9-.5 5.4-2 5.9-5.9Z"></path><path d="M15.6 13.4c.2 1.5.8 2.1 2.3 2.3-1.5.2-2.1.8-2.3 2.3-.2-1.5-.8-2.1-2.3-2.3 1.5-.2 2.1-.8 2.3-2.3Z"></path></svg>
        <span><b>Halcy</b> wants to</span>
      </p>
      <p class="ask__what" data-what>send 3 emails to the design team</p>

      <div class="btnwrap" data-wrap>
        <button class="btn" type="button" data-btn aria-live="polite">
          <span class="btn__glow" data-press-glow aria-hidden="true"></span>
          <span class="btn__fill" data-fill aria-hidden="true"></span>
          <span class="btn__in">
            <svg class="btn__icon" viewBox="0 0 20 20" aria-hidden="true">
              <path class="btn__shield" data-shield d="M10 2.6 16 4.9v4.6c0 3.7-2.5 6.4-6 7.9-3.5-1.5-6-4.2-6-7.9V4.9Z"></path>
              <path class="btn__check" data-check pathLength="1" d="M6.6 10.2 8.9 12.5 13.6 7.6"></path>
            </svg>
            <span class="btn__label" data-label></span>
          </span>
        </button>
        <svg class="beam" data-beam aria-hidden="true">
          <defs>
            <filter id="beamBlur" x="-30%" y="-80%" width="160%" height="260%"><feGaussianBlur stdDeviation="3.2"></feGaussianBlur></filter>
            <filter id="headBlur" x="-30%" y="-80%" width="160%" height="260%"><feGaussianBlur stdDeviation="1.4"></feGaussianBlur></filter>
          </defs>
          <path class="beam__track" data-track pathLength="1"></path>
          <path class="beam__halo" data-halo pathLength="1" filter="url(#beamBlur)"></path>
          <path class="beam__line" data-line pathLength="1"></path>
          <path class="beam__head" data-head pathLength="1" filter="url(#headBlur)"></path>
          <path class="beam__core" data-core pathLength="1"></path>
          <path class="beam__flash" data-flash pathLength="1" filter="url(#headBlur)"></path>
        </svg>
      </div>

      <p class="ask__hint" data-hint></p>
    </section>

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

18 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 “Hold to approve agent” 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

In the middle of an almost black background, with a barely there cold light underneath, is the request of an invented assistant: a small drawn star, «Halcy wants to», and below, larger, «send 3 emails to the design team». Then the button’s dark pill, with a thin outlined shield and the label Hold to approve, and round its border a barely visible line. Below, in grey, «Press and hold to approve». On pressing, the button shakes by one pixel, squashes to 96%, its shadow tightens and a blue reflection lights up under the finger; the line below becomes «Keep holding». Meanwhile a blue light sets off from the top of the border and runs clockwise, with a white head and a blurred halo, faster and faster, and the pill swells slightly as the light goes on, while a veil of light rises inside. Let go before the end and the light runs back in half a second, the pill bounces into place on a spring and the line goes back as it was. Hold to the end and the light closes the loop: a white flash runs once all the way round, the halo widens and settles, the border turns light green, the shield takes colour and a check draws itself inside, the label rolls letter by letter to Approved and below appears «Sending now, you can undo in Activity». After a couple of seconds everything fades and goes back to the start. A drawn pointer tries it by itself: the first time it lets go halfway, the second it holds to the end.

How it works

The border is a path

An SVG a little larger than the button holds six paths with the same drawing, the pill traced clockwise from the top centre, recomputed on resize to the real size. With pathLength set to 1 the border’s length is always 1, and the charge is just a strokeDasharray going from 0 to 1.

Head, line and halo

The blue line draws what is charged, a thicker copy blurred with a Gaussian filter makes the halo, and two short white segments, moved with strokeDashoffset to the end of the charge, make the bright head. Everything reads the same number, so they never drift apart.

Press and hold

On press a tween takes the charge to 1 in HOLD_TIME seconds, with power1.in the first time and linear when resuming halfway. The button reads two values, how pressed it is and how charged: it squashes to 96% and swells by 5% of the charge. On release the charge goes back to zero with power3.out and the press with elastic.out.

The flash and the label

At the end a white segment runs once along the whole border, at most a fifth long and shorter at both ends thanks to a sine; the halo widens and settles. The label is made of letters: the old ones rise away with a 14 millisecond stagger, the new ones come in from below with back.out.

Values to change

NameFileDefaultWhat it changes
AGENTscript.jsHalcyThe name of the assistant asking for permission.
ACTIONscript.jssend 3 emails to the design teamWhat the assistant wants to do.
HOLD_TIMEscript.js1.4The seconds to hold for the light to go all the way round.
DONE_HOLDscript.js2.2The seconds it stays Approved before going back.
BEAM_GLOWscript.js1How strong the halo of the light on the border is (0 = just the line).
PRESS_SCALEscript.js0.965How much the button squashes when pressed.
SWELLscript.js0.05How much it swells while the light charges.
SPRINGscript.js1How much it bounces when you let go (0 = none).

Try them in the Playground

When to use it

For the actions of an AI assistant or an automation that need a calm confirmation (sending emails, paying, deleting, publishing), where a single click would be too easy: holding says «I am sure» without opening a confirmation dialog.

On phones

The same animation: the pill narrows to 78% of the width and its height is measured on the screen height too; a finger does the press, and the button does not open the long press menu.

With reduced motion

No shake, no squash and no spring: the light still charges along the border, the final flash is just the border lighting up and fading, the labels change with a fade and the drawn pointer stays hidden.

Pitfalls

  • With a round stroke-linecap a zero-length dash still shows as a dot: at zero charge the line must be hidden with opacity, not only with strokeDasharray.
  • Without setPointerCapture, on a phone moving the finger slightly off the pill is enough to lose the release; and without touch-action none and a blocked contextmenu, a long press opens the browser menu instead of charging the light.
  • The button squashes with GSAP on the wrapper and shakes with its own transform on the button: one element for the scale, one for the shift, otherwise the second wipes out the first.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 26 October 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