Command Palette

Search for a command to run...

Docs
Magnetic Button

Magnetic Button

Interactive magnetic button with spring physics, 3D tilt, and ripple effects for premium interactions

About

An interactive Magnetic Button that reacts to your cursor with smooth spring physics and 3D rotation. Designed for modern, premium interfaces, it adds delightful motion and depth to your CTAs.

Key features:

  • Follows mouse movement using Framer Motion's spring physics
  • 3D tilt, hover scale, and press animations
  • Customizable colors, border, shadow, scale, radius, and typography
  • Ripple effect on click with configurable color
  • Hover sheen overlay for premium feel
  • Supports links, click events, keyboard accessibility, and disabled state

Installation

Examples

Styled Variants

Multiple color schemes and styles — gradient CTA, outlined ghost pill, and subscription button with different magnet strengths and border radius values.

Hero Section CTAs

✦ Introducing MotionX

Motion-Powered Components

Beautiful animated UI components with spring physics, 3D interactions, and production-ready accessibility.

Primary + secondary CTA pair in a hero section context with custom spring stiffness, tilt angles, and hover scales.

Usage

import MagneticButton from "@/components/motionx/magnetic-button";

Basic

<MagneticButton>Get Started</MagneticButton>

Gradient with emoji

<MagneticButton
  className="bg-gradient-to-r from-violet-600 to-indigo-600 text-white"
  magnetStrength={0.35}
  borderRadius={16}
>
  🚀 Launch App
</MagneticButton>

Ghost / Outlined

<MagneticButton
  className="bg-transparent text-foreground border-2 border-foreground/20 shadow-none"
  magnetStrength={0.5}
  borderRadius={999}
>
  Learn More →
</MagneticButton>
<MagneticButton href="https://motionx.design" target="_blank">
  Visit MotionX
</MagneticButton>

Disabled state

<MagneticButton disabled>Unavailable</MagneticButton>

Custom physics

<MagneticButton
  magnetStrength={0.6}
  stiffness={200}
  damping={10}
  hoverScale={1.08}
  pressScale={0.92}
  tiltAngle={18}
>
  Bouncy Button
</MagneticButton>

Props

PropTypeDefaultDescription
childrenReactNodeButton content
classNamestringCustom CSS classes
magnetStrengthnumber0.4Pull strength toward cursor (0–1)
stiffnessnumber150Spring stiffness for physics
dampingnumber15Spring damping for physics
hoverScalenumber1.05Scale factor on hover
pressScalenumber0.95Scale factor on press
ripplebooleantrueEnable ripple effect on click
rippleColorstring"currentColor"CSS color for ripple
borderRadiusnumber12Border radius in px
tiltbooleantrueEnable 3D tilt on hover
tiltAnglenumber12Maximum tilt angle in degrees
hrefstringIf provided, acts as a link
targetstring"_self"Anchor target (only when href is set)
disabledbooleanfalseDisable all interactions
onClickfunctionClick handler

Note: All standard button HTML attributes are also supported via spread props. The component is fully keyboard accessible — pressing Enter or Space triggers the click handler.