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 magnetic

Usage

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.

PropTypeDefault
strength

How far the child follows the cursor, from 0 to 1.

number0.35
range

Distance in px around the element where the pull applies.

number80
disabled

Turn the effect off.

booleanfalse

Notes

  • Only reacts to a mouse — touch and pen input are ignored so taps stay precise.
  • Disabled automatically with reduced motion.