Magnetic
ProWraps any element and pulls it toward the pointer.
Installation
pnpm dlx shadcn@latest add @viewport/magnetic
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| strength | numberHow far the element follows the pointer, from 0 to 1. | 0.35 |
| range | numberExtra pixels around the element where the pull begins. | 40 |
| className | string | — |
| children* | React.ReactNode | — |
Accessibility
- The wrapper is not focusable; your element keeps its own semantics.
- Disabled for touch input and under reduced motion.