kipluo
Free componentInteractionsReact + FlutterNavigationOnboarding

React Magnetic Button – Interactive Magnetic UI Component

Explore a customizable magnetic button for React. Adjust attraction strength, spring stiffness, damping, colours, and shadow. Copy code or install directly.

Live interactive demo · Move your pointer near the button.
Motion preview loop

Live vector preview rendered straight from the same 120 Hz spring engine—no heavy GIF compression artifacts, zero layout shift.

Customization playground

Tune outline, fill, accent, text colour, and shadow direction live above. The snippet updates automatically for copy-and-paste.

Customize

Colours
Shadow
<MagneticSurface />

Installation

Install directly into your project source with the Kipluo CLI (React/Tailwind v4) or add the matching Flutter package.

Install

$ npx kipluo add magnetic-surface

Working code example

magnetic-surface.tsx
import { MagneticSurface } from "@/components/kipluo/magnetic-surface";

export function HeroCta() {
  return (
    <MagneticSurface strength={0.35} radius={96}>
      <button
        type="button"
        className="rounded-full bg-primary px-6 py-3 font-semibold text-primary-foreground"
      >
        Start free trial
      </button>
    </MagneticSurface>
  );
}

What Magnetic Surface does

  • Measures pointer offset relative to the element's bounding box on every pointermove event and maps it to a bounded attraction vector.
  • Drives translation through a 120 Hz semi-implicit Euler spring so the button accelerates smoothly toward the cursor and snaps back with natural overshoot on pointer leave.
  • Disables magnetic drift automatically on coarse/touch pointers and under prefers-reduced-motion so mobile taps and keyboard users stay rock solid.

Accessibility & sound behavior

Keyboard & screen readers: The child stays a normal focusable element. Keyboard focus gives a gentle lift instead of the pointer pull.

Reduced motion: Automatically respects prefers-reduced-motion: reduce by snapping spring targets immediately without jarring travel.

Sound cues: A soft whoosh when the pull engages, a tiny tick when snapping to the center, and a lower whoosh when it lets go. Disable per instance with sound={false} or globally via setSoundEnabled(false).

API reference

strengthnumber
How far the child follows the pointer, from 0 to 1. Default 0.35.
radiusnumber
Distance in px at which the pull starts. Default 120.
springSpringConfig
How it settles back. Default { stiffness: 260, damping: 14, mass: 1 }.
disabledboolean
Turns the effect off without unmounting. Default false.
soundboolean
Plays this component's sounds. The global switch setSoundEnabled(false) silences every component. Default true.

Framework compatibility

Platform / ToolStatusDetails
React 18 & 19Full supportZero peer runtime lock-in beyond @kipluo/core.
Next.js App RouterFull supportShips with 'use client' boundaries; SSR-safe hydration.
Vite / Remix / AstroFull supportStandard ESM TypeScript source files you own.
Tailwind CSS v4 & shadcn/uiNativeInherits CSS variables and installs via shadcn registry or CLI.
Flutter (Dart)Native packageMatching spring physics, themes, and PCM audio in packages/flutter/kipluo.

Build it yourself: related tutorials

All tutorials →