Open Magnetic Button with its live demo →
Magnetic Button
A button that gently follows the pointer for a magnetic feel.
Usage
Copy src/MagneticButton.tsx into your React project. No extra dependencies.
tsx
import { MagneticButton } from "./MagneticButton";
export function Example() {
return <MagneticButton>Get started</MagneticButton>;
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
strength | number | 0.35 | How far the button follows the pointer, from 0 (still) to 1 |
className | string | Extra class on the button |
Notes
- Client component (
"use client") - Uses pointer move within a small radius around the button
- Respects
prefers-reduced-motion