Magnetic
A wrapper that pulls its child toward the cursor with spring physics.
motion
Installation
$ pnpm dlx shadcn@latest add @soultel/magneticNo namespace set up? npx shadcn@latest add https://asafefe.dev/r/magnetic.json works too.
Manual installation
- 1. Install the dependencies.
terminal1 lines npm install motion - 2. Copy the source from the Code tab into components/magnetic.tsx.
Usage
import { Magnetic } from "@/components/magnetic"
export function Example() {
return (
<Magnetic strength={0.5}>
<button>Hover me</button>
</Magnetic>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| strength | number | 0.4 | Share of the cursor offset to follow. |
