Magnetic
Pulls its child toward the cursor with a spring when it gets close. Subtle by default, playful if you want.
Motion
Playground
Tweak the props, the preview and the code follow.
Props
0.35
80
import { Magnetic } from "@/components/ui/magnetic"
<Magnetic>
<Button>Hover near me</Button>
</Magnetic>Installation
npx @plumsydev/plum-ui add magneticUsage
import { Magnetic } from "@/components/ui/magnetic"<Magnetic strength={0.35} range={80}>
<Button>Start building</Button>
</Magnetic>Examples
Nested
Nest two magnets so the icon travels further than its button — instant depth.
Strength & range
Visualize the field of influence and tune it live.
0.40
0.40
100px
API Reference
Magnetic
Extends motion.div.
| Prop | Type | Default |
|---|---|---|
strengthHow far the child follows the cursor, from 0 to 1. | number | 0.35 |
rangeDistance in px around the element where the pull applies. | number | 80 |
disabledTurn the effect off. | boolean | false |
Notes
- Only reacts to a mouse — touch and pen input are ignored so taps stay precise.
- Disabled automatically with reduced motion.