BT-04Buttons
Magnet Button
A call-to-action button wrapped in a field of iron filings that align to its magnetic field and lean toward your cursor.
PROPay Button and more like it are in Kokonut UI Pro
Installation
Magnet Button is a free, open-source React component in the Kokonut UI Buttons collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/attract-button.tsx, so the code is yours to change.
npx shadcn@latest add @kokonutui/attract-buttonOr add it by hand: install its packages, then copy the source from Copy code above into components/kokonutui/attract-button.tsx.
npm install lucide-reactUsage
import AttractButton from "@/components/kokonutui/attract-button";
export default function Example() {
return <AttractButton />;
}Props
densitynumberDefault 1Filing density. 1 places a filing roughly every 12px; 2 doubles it.
radiusnumberDefault 64How far, in px, the field of filings extends past the button's edges.
containerClassNamestringClasses for the wrapper that holds the button and its field.
Also takes every prop of ComponentProps<"button">.
Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react | ^0.556.0 | npm, installed by the CLI |
cn from lib/utils.ts | shadcn init | |
| React | 19 | Your app |
| Tailwind CSS | 4 | Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.

