A tactile luxury retail CTA button that magnetically tracks pointer proximity, morphs cleanly from Add to Bag → Loading → Added ✓, pops the cart badge with spring overshoot, and fires subtle micro-confetti.
'use client'
import { useState } from 'react'
export function MagneticAddToBag({ onAdd }: { onAdd?: () => void }) {
const [offset, setOffset] = useState({ x: 0, y: 0 })
const [status, setStatus] = useState<'idle' | 'loading' | 'done'>('idle')
const handleClick = () => {
if (status !== 'idle') return
setStatus('loading')
setTimeout(() => {
setStatus('done')
onAdd?.()
setTimeout(() => setStatus('idle'), 1200)
}, 500)
}
return (
<button
type="button"
onClick={handleClick}
onPointerMove={(e) => {
const r = e.currentTarget.getBoundingClientRect()
setOffset({ x: (e.clientX - (r.left + r.width / 2)) * 0.16, y: (e.clientY - (r.top + r.height / 2)) * 0.28 })
}}
onPointerLeave={() => setOffset({ x: 0, y: 0 })}
style={{
transform: `translate(${offset.x}px, ${offset.y}px)`,
background: status === 'done' ? '#15803d' : '#1c1917',
}}
className="inline-flex h-13 w-full items-center justify-center gap-2 rounded-full px-6 text-sm font-semibold text-stone-50 shadow-xl transition-all duration-200"
>
{status === 'loading' && <span className="h-4 w-4 animate-spin rounded-full border-2 border-white/30 border-t-white" />}
{status === 'idle' ? 'Add to Bag' : status === 'loading' ? 'Adding…' : 'Added to Bag ✓'}
</button>
)
}Loading single-file HTML…
Build a single-file luxury E-Commerce Magnetic Add-to-Bag CTA card using pure HTML, CSS, and vanilla JS on a warm ivory surface (#f5f1ea). - Magnetic & Morph Physics: Apply smooth damped pointer translation toward cursor position on hover; on click transition cleanly through Loading (CSS spinner) → Added to Bag ✓ (emerald confirmation) while bouncing a top-right Bag Counter pill using cubic-bezier(0.34, 1.56, 0.64, 1) and emitting 12 lightweight radial CSS micro-confetti sparks. - Styling: Warm editorial retail palette (#c87d32 accent & #1c1917 espresso ink), clean stock badge, touch-safe click behavior, and zero dependencies.
WHY THIS WORKS IN PRODUCTION
- Tactile magnetic pointer pull + Loading → Checkmark state morph
- Spring-overshoot cart counter badge + pure-CSS radial micro-confetti
- Directly boosts perceived polish on Shopify, Next.js & mobile storefronts
- 2.6 KB zero-dependency code + ready React/Tailwind component
DROP-IN SPECS // WEB & MOBILE FIT









