Logo

    Magnetic Button

    A button that subtly drifts toward the cursor as you hover, with a spring-based return when you leave.

    Installation

    Run the following command

    npx shadcn@latest add @aceternity/magnetic-button

    Props

    MagneticButton Props

    PropTypeDefaultDescription
    childrenReact.ReactNodeThe element to wrap with the magnetic effect. Pass any button or interactive element.
    strengthnumber0.8How strongly the child follows the cursor. 1 matches the cursor 1:1; lower values produce a softer pull.
    maxDistancenumber100Maximum distance, in pixels, that the child can drift from its resting position regardless of how far the cursor moves.

    Build websites faster and 10x better than your competitors with

    Aceternity UI Pro

    Next.js 15, Tailwind CSS v4 and Motion for react powered templates

    200+ templates and blocks combined

    Ready to copy paste component blocks, save days of development time

    Aceternity UI Pro Demo - Light Mode

    ceternity UI

    Access an ever-growing collection of premium, meticulously crafted templates and Component Blocks.

    A product by Aceternity
    Building in public at @mannupaaji

    © 2026 Aceternity Labs LLC. All Rights Reserved.