All motion recipes

Interface motion / CSS

Magnetic button

A button follows a nearby pointer and settles back on release.

Magnetic button, DKC reference still

DKC reference implementation; not an original creator video. You can play, pause, and inspect time in the reference.

Make it fit your project.

Your brief stays in this browser. Preparing a prompt does not send it to a server.

Measure the pointer relative to the button center. Clamp translation to 8px and ease back to zero when the pointer leaves. Keep the hit area fixed, use transform only on an inner surface, and preserve a visible keyboard focus ring.

Build and check.

  1. Confirm the supplied content, target environment, and required assets before implementing.
  2. Measure the pointer relative to the button center. Clamp translation to 8px and ease back to zero when the pointer leaves. Keep the hit area fixed, use transform only on an inner surface, and preserve a visible keyboard focus ring.
  3. Implement idle, active, keyboard, touch, reduced-motion, and failure states as relevant.
  4. Inspect the opening, midpoint, and final state at desktop and mobile sizes; report any dependency or output limitation.

Know the limits.

  • Do not move the actual hit target. Touch and reduced-motion users get a stationary button.
  • The prompt guides a coding agent; output quality depends on its implementation and review.

Want us to build it?

Send an optional project brief. We’ll receive your contact details, project description, and this recipe’s ID.

By sending this brief, you agree to our privacy policy. Prefer a conversation? Book a strategy call.

Catalog 2026-10-22.a82e12098f76 · Source revision sha256:dfbe6519cbc4fc84acc4cbf926d8a01c7f2e248dd46cedd67a9112b0e928c2ba