Skip to content

Magnetic Button

A button that leans toward the pointer as it approaches and springs back when it leaves, its label floating above the surface.

2 variantsProNew

Preview

Preview

Installation

Magnetic Button is part of Floret Pro. It follows Floret's theme tokens, so light and dark mode work out of the box.

Floret ProPro

Your license unlocks this component and all of its source. Sign in once, then install it with the CLI. Follow the steps below.

  1. Sign in with your license

    Paste the key from your purchase email. Once per computer.

    pnpm dlx @shipped-ui/floret login <license-key>
  2. Add Magnetic Button

    The CLI checks your license, then copies the source with every dependency and theme token.

    pnpm dlx @shipped-ui/floret add magnetic-button

Usage

Pass your own data and wire the callbacks to your app.

import { MagneticButton } from "@/components/ui/magnetic-button";

export function Hero() {
  return <MagneticButton onClick={() => start()}>Get started</MagneticButton>;
}

Props

PropTypeDefaultDescription
strengthnumber14How far, in px, the button may travel toward the pointer.
radiusnumber48Extra reach around the button, in px, where the pull starts.
classNamestring—Merged onto the button.