Back to components
ComponentEffectFree

Magnetic Button React component

A button that's pulled toward the pointer as it comes near, with its label drifting a little further for depth, a fill that sweeps in from the side you entered, and a springy wobble back into place when you move away.

About the Magnetic Button component

Magnetic Button leans toward your pointer as it gets close, as if pulled by a magnet, and its label drifts a little further than the button itself so it feels like it has depth. Move away and it springs back with a soft wobble.

It can also sweep a fill colour in from whichever side you came from, flipping the label colour to stay readable. It's a real button or link underneath, so keyboard and screen-reader use are unchanged.

When to use it

Use it for the one or two calls to action you want people to reach for — 'Get in touch', 'Start a project', social links — on portfolios, agency sites and launch pages.

Skip it for dense toolbars and forms: buttons that move are fun for a hero, tiring in a list of twenty.

Installation

Add the Magnetic Button component to your project with the shadcn CLI. It lands in components/magnetic-button.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/magnetic-button

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install clsx tailwind-merge

More Effect components

Orbiting Border Glow
Free
Click Burst
Free
Target Lock Cursor
Free
Image Mask Reveal
Free
Fluid Ink Cursor
Free
Entrance Reveal
Free