Build log

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 button

Magnetic pull at 35% of cursor offset · global cursor expands via data-cursor-morph

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> )}
Asked
Build a magnetic 'View case studies' button that feels tactile and precise. The interaction should support the intent to explore, not perform craft. Keep it readable, accessible, and cheap to render.
Came back
The first pass pulled at half the cursor delta and the button felt like it was chasing the pointer: the label drifted off its visual anchor and the focus ring wandered with it. I cut the pull to 0.35. Lower and the response is invisible; higher and it reads as a trick. At 0.35 the button stays inside its own footprint, so the label, the hit target, and the focus ring all stay put. The spring was retuned for precise on entry and calm on exit, and the global cursor was given a morph attribute so it expands to the button's shape at the same moment the button leans in. They meet partway.
Kept
Two motion values through one spring, transform-only so it stays smooth on weak hardware, and a cursor that wraps the button as the button pulls toward it. Responsiveness reads as a property of the interaction, not a performance of it.