MagneticButton

Leans toward the cursor, label drifting further, and springs back. Buttons.

Open playground

About

MagneticButton is a React component in the Buttons category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { MagneticButton } from "@ashutoshswamy/smoui" and set children, strength, onClick.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { MagneticButton } from "@ashutoshswamy/smoui";

<MagneticButton className="rounded-full bg-black px-6 py-3 text-white">Hover me</MagneticButton>

Props 3

children

Button content.

ReactNode
strength

0-1, how far it follows the cursor.

numberdefault 0.35
onClick

Click handler.

() => void