Pro
Magnetic
Wraps one button or link so it leans toward the pointer as it comes near, up to 8px, and settles back when the pointer leaves.
pnpm dlx shadcn@latest add @caliper/magneticWhen to use
Use it for
- The one or two actions you want people to notice, such as a hero button.
- Marketing and onboarding surfaces where a little life helps.
Skip it when
- Dense toolbars and tables; many things leaning at once is noise.
- Touch and keyboard: it does nothing there, so nothing may depend on it.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Only the wrapper moves
- The control inside keeps its own press, focus ring and hit area, so activation never changes. The lean is a follow with a soft settle, not a spring that overshoots.
- Fine pointers only
- Touch, keyboard focus and reduced motion get no lean at all. Nothing important may depend on it.
Usage
- Wrap one child
- A lean larger than 8px starts to feel like the button is running away, so the limit is part of the part.
Installation
pnpm dlx shadcn@latest add @caliper/magnetic
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
Import it from your copy of the source. The example behind the preview comes with the source.
import { Magnetic } from "@/components/ui/magnetic"
The worked example comes with Pro
The 27-line example behind the preview opens here, ready to copy.
- 626 Pro parts, blocks and page templates, all with source
- $149 once, with lifetime updates. No renewal
- A full refund within 14 days if it is not for you
API reference
Magnetic
component
Also accepts the native props of its root element and a ref.
Accessibility
It is built on native elements, so roles and focus come from the browser.
No custom key handling; Tab and the native activation keys do the work.
Motion
It checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.
Related
- ButtonA familiar action with immediate focus, a tactile press, and optional pending or label feedback that stays on the button itself.
- Split buttonA primary action joined to its alternatives; the chosen option becomes the label.
- Action buttonA button that runs async work and reports progress, success or failure on itself, at one width.