Magnet Button - React Component | Kokonut UI

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.

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-button

Or add it by hand: install its packages, then copy the source from the above command into components/kokonutui/attract-button.tsx.

npm install lucide-react

Usage

import AttractButton from "@/components/kokonutui/attract-button";

export default function Example() {
  return <AttractButton />;
}

Props

density

radius

containerClassName

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.