Skip to content
animorio
IT
All components

Perfume add to bag button

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

The small card of a perfume from an invented perfumery, Maison Odile, with a real photo of a green glass bottle with a silver atomizer in the sun, and under it the dark glass Add to bag button with the bag and its count. Pressed, a piece of the photo with the bottle comes away, rounds off and flies on a curve to the bag inside the button; the bag swallows it, the button swells on a spring, a reflection runs across the glass, the words turn into Added with a drawn check and the bag’s count rolls up. Then it goes back to rest.

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>
<!--
  "Perfume add to bag 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 to bag button with the perfume bottle that flies into it</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" data-stage>
    <!-- a small product card of an invented perfumery, Maison Odile, with a real photo of a green glass bottle. Add to
         bag: a little picture of the bottle leaves the photo, flies on a curve into the bag inside the button, the
         button swells on a spring, the words become Added with a drawn check and the bag's count rolls up -->
    <article class="card" data-card aria-label="Maison Odile, Verre de Jardin eau de parfum">
      <figure class="card__pic" data-pic>
        <span class="card__photo" data-photo>
          <img class="card__img" src="boccetta.webp" width="1024" height="768" alt="A green glass perfume bottle with a silver atomizer on a wooden table, in the sun, with a garden out of focus behind">
        </span>
        <span class="card__glint" data-glint aria-hidden="true"></span>
        <span class="card__chip">50 ml</span>
      </figure>

      <div class="card__info">
        <div class="card__row">
          <p class="card__house">Maison Odile</p>
          <p class="card__price">$138</p>
        </div>
        <p class="card__name">Verre de Jardin <span class="card__kind">Eau de parfum</span></p>
        <p class="card__notes">Fig leaf, vetiver, cut grass</p>
      </div>

      <div class="cta" data-cta>
        <button class="cta__btn" type="button" data-btn data-autoclic aria-describedby="bag-live">
          <span class="cta__body" data-body>
            <span class="cta__skin">
              <span class="cta__sheen" data-sheen aria-hidden="true"></span>
              <span class="cta__words" aria-hidden="true">
                <span class="cta__word cta__word--add" data-add>Add to bag</span>
                <span class="cta__word cta__word--done" data-done>
                  <svg class="cta__check" viewBox="0 0 16 16"><path data-check pathLength="1" d="M3.2 8.6l3 3 6.6-7"/></svg>
                  <span>Added</span>
                </span>
              </span>
              <span class="sr">Add to bag</span>
              <span class="cta__well" data-well aria-hidden="true">
                <svg class="cta__bag" data-bag viewBox="0 0 24 24">
                  <path class="cta__bag-handle" data-handle d="M8.6 9.2V7.4a3.4 3.4 0 0 1 6.8 0v1.8"/>
                  <path class="cta__bag-body" d="M5.4 8.6h13.2l-0.9 10.6a1.6 1.6 0 0 1-1.6 1.5H7.9a1.6 1.6 0 0 1-1.6-1.5z"/>
                  <path class="cta__bag-lip" data-lip d="M5.6 8.6h12.8"/>
                </svg>
                <span class="cta__count" data-count>
                  <span class="cta__digits" data-digits><span>0</span><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span></span>
                </span>
              </span>
            </span>
          </span>
        </button>
      </div>
    </article>

    <!-- the little picture of the bottle that flies into the bag -->
    <span class="fly" data-fly aria-hidden="true"><span class="fly__img"></span><span class="fly__shine"></span></span>

    <!-- the drawn pointer of the autopilot -->
    <svg class="pointer" data-pointer viewBox="0 0 24 24" aria-hidden="true">
      <path d="M5 3.2l13.4 9.1-6 1.1 3.5 6.6-2.7 1.4-3.5-6.6-4.6 4z"/>
    </svg>

    <p class="sr" id="bag-live" 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.

35 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 “Perfume add to bag 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 white a white card with round corners and a soft layered shadow rises gently. At the top the real photo of a stepped green glass perfume bottle, with a silver atomizer, on a wooden table in the sun, with a garden out of focus behind and another bottle cut by the edge beside it; in a corner a small frosted glass label says 50 ml. Below, the house Maison Odile in wide capitals, the price $138, the name Verre de Jardin with Eau de parfum and the notes, Fig leaf, vetiver, cut grass. At the bottom the pill button, 60 pixels tall, of dark glass with a soft light at the top, a bright thread on the edge and a very fine grain; on the left Add to bag, on the right a round well with the drawn bag and a small green count, 2. Hovering, the button rises by a pixel and a half, the green shadow under it widens and a reflection runs across the glass; pressing it squashes it. On click the photo gives a small kick and a flash of light crosses it; the piece of the photo with the bottle lifts, rounds off into a circle, turns slightly and flies on a high curve to the well, shrinking. There the bag swallows it, squashing, and its handles jump, the button swells by 4% and springs back, a green glow rises from the well and a reflection crosses the whole glass. Add to bag leaves at the top and from below comes Added with the green check drawing itself; the bag’s count rolls from 2 to 3 and swells for a moment. After a couple of seconds Added leaves at the top, the check is wiped and Add to bag comes back on a spring. In the preview a drawn pointer arrives, presses and leaves, and the count goes up every round.

How it works

A button in two layers

The button is a body (.cta__body) that GSAP lifts, squashes and swells, and inside it a skin (.cta__skin) that gets the dark glass from CSS: two gradients, a thread of light at the top with an inset box-shadow, a grain made with feTurbulence in overlay and the green shadow. The glow that rises from the bag is an ::after with its opacity in a CSS variable, --glow, which GSAP animates.

A piece of the photo comes away

The script works out where the bottle is inside the photo from object-fit: cover and object-position (scale, offset, and the bottle’s point in the image), and prepares the flying circle with the same image as its background, sized and offset in pixels like the photo: on the first frame it really is the piece of the photo, then it lifts with a longer shadow.

The flight on a curve

An object p goes from 0 to 1 and at each step the circle is placed on a cubic Bézier curve: it starts at the bottle, rises with the first control point, falls from above onto the bag’s well with the second. Start and end are read from the page at every step, so if the window changes size halfway through the flight the circle still lands in the well. Meanwhile it shrinks with power2.in, turns a few degrees halfway and its corner radius grows into a circle.

The landing on a spring

The ease is a true spring written as a function, a damped oscillator that settles by the end of the tween, with its strength taken from SPRING. On landing the bag squashes towards its bottom and the handles jump, the body swells and comes back, the two labels swap in a window with yPercent and the check draws itself with stroke-dashoffset on pathLength 1.

The rolling count

The bag’s count is a column of ten digits in a round window 18 pixels tall: to change number the column slides by yPercent, -10 for each digit, on the same spring, and the window swells for a moment. A reflection is a narrow gradient crossing the glass with xPercent, on hover and on landing.

Values to change

NameFileDefaultWhat it changes
START_COUNTscript.js2How many items are already in the bag at the start, from 0 to 8.
ACCENTscript.js#3f9b78The one accent colour, the green of the glass: the bag’s count, the check, the glow.
FLIGHTscript.js0.95The seconds of the bottle’s flight from the photo to the bag.
ARCscript.js1How high the flight’s curve rises: 0 almost straight, 2 very high.
SPRINGscript.js1How springy the button is when the bottle lands: 0 none, 2 double.
HOLDscript.js1.9The seconds it stays on Added before going back to rest.
PAUSEscript.js1.3The seconds the autopilot waits between one round and the next.
AUTOscript.jstrueThe autopilot presses the button by itself until someone touches it.

Try them in the Playground

When to use it

For the product page or card of an online store: a perfumery, a cosmetics or beauty shop, a candle, a wine, a piece of jewellery, anything with a beautiful photo. It says without opening anything that the item went into the bag and how many there are, and the flight joins the photo to the bag in a single gesture.

On phones

The same animation with adapted sizes: the card is almost as wide as the screen, the photo and the button get lower with the height (the button goes down to 50 pixels on short screens) and on the shortest ones the notes disappear. With a finger the button squashes and springs back; the hover reflection is only there with a pointer.

With reduced motion

Nothing moves: the bottle does not fly, the labels Add to bag and Added swap with a fade, the check appears already drawn, the bag’s count changes in place with a fade and the green glow lights up and fades. The drawn pointer is not there.

Pitfalls

  • The flying circle with its image in cover started with a different framing of the bottle and the jump showed: its background has the same size and offset in pixels as the photo, worked out from object-fit and object-position.
  • With GSAP’s transform on the button, the press, the hover and the swell on landing cancelled each other when they sat on the skin with the CSS shadows: GSAP moves only the body, the skin stays with CSS.
  • The flying circle inside the card was clipped by its edge and shadows: it lives outside, in the stage, and is placed with rectangles read from the page.
  • The round started when the script was read and the poster landed on different moments: it starts from the load event.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 8.9 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