Skip to content

Magnetic Cursor Button

Button that attracts toward the users cursor with smooth inertia and premium feel

ButtonsAdvancedInteractiveExpertHTML/CSSReactVueAngularSvelte
Magnetic Cursor Button

by FreeCsStyles Dev's

AdvancedInteractive
🌐⚛️💚🅰️🔥
#magnetic#cursor#tracking#premium#interactive#luxury

Embed this component

Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/magnetic-cursor-button.

<iframe src="/embed/magnetic-cursor-button" sandbox="allow-scripts" loading="lazy" title="Magnetic Cursor Button" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>

Implementation code

Copy the HTML and CSS for Magnetic Cursor Button, or grab a framework-specific implementation. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.

HTML
<button class="magnetic-cursor-btn">🧲 Attract</button>
CSS
.magnetic-cursor-btn {
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #f1f5f9;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}
.magnetic-cursor-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.magnetic-cursor-btn:active {
  transform: scale(0.94);
}
Tailwind CSS
<button class="px-8 py-4 rounded-xl font-semibold bg-gradient-to-br from-slate-800 to-slate-700 text-slate-100 border border-white/10 hover:scale-106 active:scale-94 transition-all">
  🧲 Attract
</button>
React
function MagneticCursorButton() {
  return (
    <motion.button
      className="px-8 py-4 rounded-xl font-semibold"
      style={{ background: 'linear-gradient(135deg, #1e293b, #334155)', color: '#f1f5f9', border: '1px solid rgba(255,255,255,0.1)' }}
      whileHover={{ scale: 1.06, boxShadow: '0 20px 40px rgba(0,0,0,0.2)', transition: { type: 'spring', stiffness: 200, damping: 8 } }}
      whileTap={{ scale: 0.94 }}
    >
      🧲 Attract
    </motion.button>
  );
}
LWC — HTML template
<template><button class="magnetic-cursor-btn" onclick={handleClick}><slot>🧲 Attract</slot></button></template>
LWC — JavaScript
import { LightningElement, api } from 'lwc';
export default class MagneticCursorButton extends LightningElement {
  @api label = '🧲 Attract';
  handleClick() { this.dispatchEvent(new CustomEvent('buttonclick', { bubbles: true, composed: true })); }
}
LWC — CSS
.magnetic-cursor-btn { padding: 1rem 2rem; border-radius: 0.75rem; background: linear-gradient(135deg, #1e293b, #334155); color: #f1f5f9; font-weight: 600; border: 1px solid rgba(255,255,255,0.1); cursor: pointer; transition: all 0.3s ease; }
.magnetic-cursor-btn:hover { transform: scale(1.06); box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.magnetic-cursor-btn:active { transform: scale(0.94); }
LWC — Configuration
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>59.0</apiVersion>
  <isExposed>true</isExposed>
  <targets><target>lightning__AppPage</target><target>lightning__RecordPage</target><target>lightning__HomePage</target></targets>
</LightningComponentBundle>

Where Magnetic Cursor Button fits

  • Agency Websites
  • Premium Products
  • Luxury Brands
  • Interactive Demos

Interaction states & animations

  • Magnetic
  • Cursor Tracking
  • Spring Return
  • Parallax

Topics

  • #magnetic
  • #cursor
  • #tracking
  • #premium
  • #interactive
  • #luxury

Accessibility notes

Provide non-magnetic fallback for users with motor impairments. Maintain full keyboard navigation.

Browser support

  • All modern browsers