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.

Shop

Headphones$89

Camera$249

Mug$14

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.

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 GitHub

What it is

The full explanation is in README.md.

Good for

  • Online shops
  • Product lists
  • Food ordering
  • Wish lists

Avoid on

  • Bulk order forms
  • Quick reorder lists