Interactioncomponents/Hero.tsx+1 more
A little intrigue
A button that leans toward the pointer invites a second look. One that chases it reads as a trick.
Hover the buttonDesktop demo · hover required
Magnetic pull at 35% of cursor offset · global cursor expands via data-cursor-morphOpen this card on a desktop with a mouse to feel the effect.
components/Hero.tsx
function MagneticButton({ href, children, className }) { const x = useMotionValue(0) const y = useMotionValue(0) const sx = useSpring(x, { stiffness: 200, damping: 12, mass: 0.1 }) const sy = useSpring(y, { stiffness: 200, damping: 12, mass: 0.1 }) function onMove(e: React.MouseEvent<HTMLDivElement>) { const r = e.currentTarget.getBoundingClientRect() x.set((e.clientX - (r.left + r.width / 2)) * 0.35) y.set((e.clientY - (r.top + r.height / 2)) * 0.35) } function onLeave() { x.set(0); y.set(0) } return ( <motion.div style={{ x: sx, y: sy, display: "inline-flex" }} onMouseMove={onMove} onMouseLeave={onLeave}> <a href={href} data-cursor-morph className={`inline-flex items-center pl-[2px] pr-8 py-3 rounded-full ${className ?? ""}`}> {children} </a> </motion.div> )}