Magnetic Button
Button that magnetically follows the cursor; the label leans a little further for parallax, with a spring press state. Solid, accent and glass surfaces.
Try it: Move near the button — it pulls toward you. Press to feel the spring.
Installation
Install with the shadcn CLI:
npx shadcn@latest add https://www.framekitui.live/r/magnetic-button.jsonOr, with the @framekit namespace registered: npx shadcn@latest add @framekit/magnetic-button. You can also copy the source into components/ui/magnetic-button.tsx (view on GitHub).
Usage
import { MagneticButton } from '@/components/ui/magnetic-button'Props
| Prop | Type | Default | Notes |
|---|---|---|---|
strength | number | 0.35 | How far the button follows the pointer (fraction of the offset). |
variant | 'solid' | 'accent' | 'glass' | 'solid' | Surface style. |
...props | ButtonHTMLAttributes | — | Forwarded to the button. |
Dependencies
motion
Related Buttons components
- Spark Button
Click bursts into particle sparks.
- Focus Bloom Button
Focus/hover bloom steered by pointer.
- Liquid Fill Button
Liquid rises to fill on hover or press.
- Inkline Action
Text action with a seeded ink underline.
- Split Reveal Button
Face splits open to reveal the label.
- Orbit Commit
Hold to confirm while an icon orbits the rim.