Kinetic UI
Back to Introduction
Buttons

Magnetic Button

A button that snaps and physically pulls towards the user's cursor on hover using spring physics.

Quick Actions
CLI Installation
npx kinetic-ui-cli@latest add magnetic-button

The MagneticButton uses Framer Motion's robust spring physics to create a highly tactile, physical interaction. When a user hovers near or over the button, it pulls towards their cursor, snapping back into place when they leave. Now featuring 3 physics variants to simulate different physical materials.

Live Preview

Magnetic Button

Standard Magnet:A balanced spring physics configuration for a snappy pull.

Usage Guide

1. Import the Component

Import the component into your React or Next.js page:

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

2. Implementation Example

Render the component and customize its behavior by passing props:

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

export default function Example() {
  return (
    <div className="w-full flex items-center justify-center p-8">
      <MagneticButton
        magneticPull{10}
        scale{10}
        speed{10}
      >
        <div>Content goes here</div>
      </MagneticButton>
    </div>
  );
}
Performance Notes
  • Uses CSS hardware acceleration via GPU transform-binds.
  • Damped interpolation minimizes paint-redraw flashes.
  • Tree-shakable import: only compiles elements requested.
Accessibility Notes
  • Full keyboard focus-ring navigation support (`Tab`/`Shift+Tab`).
  • ARIA roles mapped correctly for assistive screen readers.
  • Respects `prefers-reduced-motion` system toggles.