Skip to content
animorio
IT
All components

Try at home button

Buttons, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 8.3 KBGSAP 28 KBFreeDownload the zip

The Try at home button of a made-up eyewear shop, Halden Optical: the three frames picked sit stacked on the right of the dark pill, on little paper cards. On hover the stack fans open; on the tap the pill grows, three slots open and each frame jumps from the stack into its own, the lid with the pressed-in name comes down and the amber tape seals it, a light runs along the tape while a courier is booked and the box becomes a green tick with the day it ships.

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>
<!--
  "Try at home 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 Try at home button with three glasses frames packed into the box</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- the Try at home button of a made-up eyewear shop, Halden Optical: the three frames you picked sit stacked on
         the right of the pill; one tap and each drops into its slot of a little box, the lid comes down, the tape runs
         across, a courier is booked and the pill says when the box ships. -->
    <div class="wrap" data-wrap>
      <button class="pill" type="button" data-pill aria-describedby="hint">
        <span class="pill__body" data-body>
          <span class="pill__light" data-light aria-hidden="true"></span>
          <span class="pill__sweep" data-sweep aria-hidden="true"></span>

          <span class="lead" aria-hidden="true">
            <span class="lead__well" data-well>
              <svg class="lead__box" data-box viewBox="0 0 20 20">
                <path d="M3.2 6.6 10 3.4l6.8 3.2v7L10 16.8l-6.8-3.2Z"></path>
                <path d="M3.2 6.6 10 9.8l6.8-3.2M10 9.8v7"></path>
                <path class="lead__flap" d="M6.6 5 13.4 8.2"></path>
              </svg>
              <svg class="lead__tick" data-tick viewBox="0 0 20 20"><path d="M5.4 10.4 8.6 13.4 14.8 6.8"></path></svg>
            </span>
          </span>

          <span class="say">
            <span class="say__win"><span class="say__now" data-say>Try at home</span></span>
            <span class="say__sub" data-sub>3 frames · free both ways</span>
          </span>

          <span class="tray" data-tray aria-hidden="true">
            <span class="slot" data-slot></span>
            <span class="slot" data-slot></span>
            <span class="slot" data-slot></span>

            <!-- the three frames picked: round tortoise, square black, cat-eye rose -->
            <span class="chip chip--tort" data-chip>
              <svg viewBox="0 0 40 20"><circle cx="11" cy="10.5" r="6.2"></circle><circle cx="29" cy="10.5" r="6.2"></circle><path d="M17.2 9.6q2.8-2 5.6 0M4.8 9.2 2 8M35.2 9.2 38 8"></path></svg>
            </span>
            <span class="chip chip--ink" data-chip>
              <svg viewBox="0 0 40 20"><rect x="4.4" y="5" width="12.6" height="10" rx="2.4"></rect><rect x="23" y="5" width="12.6" height="10" rx="2.4"></rect><path d="M17 8.6q3-1.6 6 0M4.4 7.4 2 6.6M35.6 7.4 38 6.6"></path></svg>
            </span>
            <span class="chip chip--rose" data-chip>
              <svg viewBox="0 0 40 20"><path d="M4 7.2q6.6-2.4 13.2-.4-.2 7.6-6.6 8.2Q4.6 15 4 7.2Z"></path><path d="M36 7.2q-6.6-2.4-13.2-.4.2 7.6 6.6 8.2 6-.0 6.6-7.8Z"></path><path d="M17.2 8.2q2.8-1.6 5.6 0M4 7.2 2 6M36 7.2 38 6"></path></svg>
            </span>

            <!-- the lid that closes the box, with the tape and the shop's name pressed in -->
            <span class="lid" data-lid>
              <span class="lid__name">Halden</span>
              <span class="lid__tape" data-tape><span class="lid__shine" data-shine></span></span>
            </span>
          </span>
        </span>
      </button>

      <p class="hint" id="hint">
        <svg class="hint__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M12.6 6.2A5 5 0 1 0 13 9.4"></path><path d="M13.2 3.4v3h-3"></path></svg>
        <span class="hint__win"><span class="hint__now" data-hint>Keep what you love, send back the rest</span></span>
      </p>
      <span class="live" aria-live="polite" data-live></span>
    </div>
  </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.

21 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 “Try at home 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 white ground sits the dark Try at home pill: on the left the box icon with its amber flap in a little well, the label and the line «3 frames · free both ways», on the right the three frames picked (round tortoise, square black, rose cat-eye) drawn on little paper cards, stacked and slightly turned. Below, the grey line with the return arrow. On hover the pill rises a pixel, a soft light follows the pointer and the stack fans open on a spring; pressed, it squashes slightly. On the tap the label rolls to «Packing your box», the pill grows, three sunken slots open and the frames jump one at a time from the stack into their slot, squash a hair as they land and the slot lights up amber. Then «Sealing the box»: the lid with the Halden name pressed in comes down with a bounce, the pill feels its weight and the amber tape runs from left to right. «Booking a courier»: a light slides along the tape and the well breathes. At the end the box spins away and becomes a green tick that draws itself with a ripple, the label says «Ships Tuesday», the line «5 days to try · free returns», a light crosses the pill and the line below rolls to the box code. Then the lid lifts, the frames go back to the stack and the pill narrows.

How it works

A button and a body

The real button only gets movement and scale from GSAP (hover, press, the weight of the lid); inside, the pill’s body changes width. This way the two animations never wipe each other’s transform, and the focus ring stays on the body.

From the stack to the slots

The frame cards are absolute inside the tray: stack and slot positions are measured in pixels (the slots’ offsetLeft) and read again on resize. Each card runs three overlapping tweens: it lifts while turning, slides sideways, drops with a back.out and squashes as it lands.

The lid and the tape

The lid comes down from yPercent -150 inside the pill, whose overflow is hidden, and sits above the cards with a fixed z-index (GSAP animates the cards’ z-index). The tape draws itself with scaleX from the left and a light inside it repeats for as long as the courier wait lasts.

Rolling lines

The big label sits in a one-line window: the new one comes in from below, the old one leaves at the top and is removed. The line under the pill does the same and also widens its window to the new sentence, so it stays centred.

Values to change

NameFileDefaultWhat it changes
LABELscript.jsTry at homeThe label of the button at rest.
SHIPSscript.jsShips TuesdayThe day the box ships, at the end.
TRIAL_DAYSscript.js5The days to try the glasses at home.
BOX_IDscript.jsHL-3307The box code in the line below.
SPRINGscript.js1How much the frames and the lid bounce.
COURIERscript.js1.1The seconds of waiting while the courier is booked.
HOLDscript.js2.4The seconds the confirmation stays before going back to rest.
IDLEscript.js1The seconds before the autopilot starts.
--nastrostyle.css#e0a458The colour of the tape that seals the box.
--tartarugastyle.css#9a5a32The colour of the tortoise frame.

Try them in the Playground

When to use it

On the page of an eyewear, shoe or clothing shop that sends products to try at home for free: after picking the models, a button that shows the box being packed and says right away when it ships.

On phones

The pill narrows within the screen width and the stack and slot positions are read again; the finger taps like the mouse. Without hover the stack stays closed and the light off.

With reduced motion

No jumps or bounces: the slots fade in, the frames fade out of the stack and back in already in place, the lid appears with the tape already on, the tick appears drawn and the lines change with a fade.

Pitfalls

  • GSAP animates the z-index of the jumping cards: without a fixed, higher z-index the lid came down behind the frames instead of covering them.
  • The centred tape covered the name pressed into the lid: it moved to the top, thinner, with the name below.
  • The line under the pill changes length with every state: with a fixed-width window the sentence was no longer centred, so the window widens to the new sentence.
  • The autopilot must stop at the first real click (event.isTrusted), or it keeps pressing over whoever is trying it.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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