Magnetic Button

A button that leans toward the mouse and springs back when it leaves.

Halden R · ships 14 October

From £1,890

import { MagneticButton } from '@brand-studio/ui';
import { ArrowRight } from 'lucide-react';

export default function MagneticButtonDemo() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: 24, width: '100%', maxWidth: 560, padding: '28px 32px', borderRadius: 20, background: 'var(--bs-elevated)', border: '1px solid var(--bs-line-soft)' }}>
      <div>
        <p style={{ margin: '0 0 4px', fontSize: 13, color: 'var(--bs-muted)' }}>Halden R · ships 14 October</p>
        <p style={{ margin: 0, fontSize: 22, fontWeight: 600 }}>From £1,890</p>
      </div>
      <MagneticButton shape="pill">Pre-order <ArrowRight size={16} aria-hidden="true" /></MagneticButton>
    </div>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { MagneticButton } from '@brand-studio/ui';
<MagneticButton shape="pill">Pre-order</MagneticButton>

It takes every Button prop. strength scales how far it leans; 1 moves the button up to 10 px.

Accessibility

  • It is an ordinary button, so keyboard and screen reader use is unchanged.
  • Only a mouse moves it. Touch, pen and reduced motion get a still button.

API Reference

PropTypeDefault
tone?"inverse" | "primary" | "secondary"–
shape?"default" | "pill"–
loading?boolean–
strength?number1

Also accepts every ButtonHTMLAttributes<HTMLButtonElement> attribute.

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.