Magnetic Button
A button that translates toward the cursor with spring physics, with the label counter-drifting to create a sense of mass.
Installation
▸ Run the following command
npx shadcn@latest add https://www.mellowui.com/r/magnetic-button.json▸ Or install manually
- Install dependencies:
pnpm add motion - Copy the source from the Code tab above.
- Place it at
components/mellow/magnetic-button.tsx - Import and use.
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | — | Button label content. |
| variant | "default" | "accent" | "default" | Color scheme — default is neutral glass, accent is purple. |
| strength | number | 0.45 | Multiplier controlling how far the button pulls toward the cursor. |