Documentation
Buttonsbuttonmagnetichover
Magnetic Button
A button that magnetically follows the cursor on hover.
magnetic-button.tsx
Installation
Terminal
1npx shadcn@latest add "https://sniper-ui-coral.vercel.app/r/magnetic-button.json"Auto-Installed Dependencies
The CLI will automatically install these packages.
Terminal
1npm install framer-motion clsx tailwind-mergeUsage
Basic
page.tsx
1import { MagneticButton } from "@/components/ui/magnetic-button";
2
3export default function MyPage() {
4 return (
5 <MagneticButton>
6 Click me
7 </MagneticButton>
8 );
9}Examples
examples.tsx
1import { MagneticButton } from "@/components/ui/magnetic-button";
2
3export default function MyPage() {
4 return (
5 <div className="flex gap-4">
6 {/* Default strength */}
7 <MagneticButton>Default</MagneticButton>
8
9 {/* Stronger pull */}
10 <MagneticButton strength={80}>Strong Pull</MagneticButton>
11
12 {/* Custom styled */}
13 <MagneticButton className="rounded-full px-6">
14 Rounded
15 </MagneticButton>
16 </div>
17 );
18}Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | — | The button content. |
className | string | — | Additional CSS classes to apply. |
strength | number | 40 | Controls how strongly the button follows the cursor. Higher = more movement. |

Sniper UI
An open-source library available on GitHub — contribute or star the repo to support it.
Categories