Components / Buttons
Magnetic Button
A button that is pulled toward the cursor with a springy, parallax label.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/magnetic-button.tsx. - 3
Use it
example.tsximport { MagneticButton } from "@/components/ui/magnetic-button"; export default function MagneticButtonDemo() { return <MagneticButton>Hover me →</MagneticButton>; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| strength | number | 0.35 | How strongly the button follows the cursor (0–1). |
| onClick | () => void | — | Click handler. |
| className | string | — | Extra classes for the button. |