Mini Cart Count

Add to cart and the bag wiggles while its badge rolls up a number

1

Create a cart icon with an animated count badge. An "Add to cart" pill button next to a shopping bag icon with a small dark count badge pinned to its top-right corner. Clicking Add does two things at once: the bag wiggles (rotate 0 → -12 → 9 → -5 → 0 over 450ms), and the badge number rolls: inside the overflow-hidden badge, the old number slides up and out while the new one springs in from below at 140% scale settling to 100% (spring stiffness 480, damping 26). The button itself dips to 92% on press. Keep the badge a fixed-size circle (about 18px, monospace bold) so single digits don't shift layout. Accessibility: the badge carries aria-live="polite" with an aria-label like "3 items in cart" so updates are announced. If prefers-reduced-motion is set, update the number instantly with no wiggle or roll. Build the component, not this demo of it. - Ambient motion that IS the component may loop: a drifting background, a marquee, a spinner while something is genuinely loading. - Do not add any timer, interval, loop or script that performs a person's action by itself. No auto-hover, no auto-click, no cycling through states, no pretend submitting, no replaying the interaction on a schedule. - Every state that answers a person waits for a real event from that person. - Placeholder copy and sample content are welcome. Simulated behaviour is not.

Rate it
0
0

We'd like to measure how the site gets used, with Google Analytics. It sets cookies. Everything the site needs to work runs either way. How we handle data