04.32 · Micro-Interactions
Add-to-Cart Fly
The product flies into the cart, which bumps and counts up. Best for shops.
Click it
Click or tap Add to cart (Reset brings the count back), or press Show me.
Headphones$89
Camera$249
Mug$14
Inside, the dashed line is the picture's path into the cart, a dot for every tenth of a second, and the outlines show it shrinking. Press Add to cart or Show me.
Count only: pressing Add to cart just changes the number; Flies to cart: a copy of the picture flies into the cart, then the number changes. Press Add to cart, or Show me.
Try it
Change a setting, then try it again or press Show me.
Flight speed
How long the copy takes to reach the cart.
Path
An arc rises and drops into the cart, like a toss.
The cart and its count jump as the copy lands.
Copy the prompt
Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.
Add an add-to-cart animation to [the Add to cart buttons of your product list]. When one is pressed, copy that product's picture and fly the copy into the cart icon, shrinking it on the way, then remove it. Move it with transforms only: for a curved path, slide it sideways at an even pace while an inner layer rises and then drops into the cart; for a straight path, move both together. As it lands, raise the number on the cart and, when the settings include it, give the cart a small bump. Tell screen readers that the item was added. If the visitor has reduced motion turned on, fly nothing and fade the new number in. Match the settings listed below.
Your settings
Replace the words in brackets with your own element. Your settings are added at the end.
Free and open source. If this helped, a star on GitHub helps other people find it.
Star on GitHubWhat it is
The full explanation is in README.md.