ham7a311

Magnetic Button

Buttons

About

A pill-shaped button that leans toward the pointer with a spring-physics pull and a soft glow, snapping back with a slight overshoot when the pointer leaves.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Magnetic Button to your project and fits it to your theme.

Code

How Magnetic Button is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import type { CSSProperties } from "react";
import { MagneticButton } from "@/components/ui/magnetic-button";

export default function Demo({ variant = "night" }: { variant?: string }) {
  const night = variant !== "paper";
  const solid = (
    night
      ? { "--bg": "#f1efe9", "--fg": "#111111" }
      : { "--bg": "#111111", "--fg": "#ffffff" }
  ) as CSSProperties;
  return (
    <div
      className="flex min-h-full w-full flex-wrap items-center justify-center gap-5 p-10"
      style={{
        background: night ? "#0d0d0f" : "#f1efe9",
        color: night ? "#f1efe9" : "#111111",
      }}
    >
      <MagneticButton style={solid}>Start a project</MagneticButton>
      <MagneticButton className="mgb--ghost">See the work</MagneticButton>
    </div>
  );
}

More by ham7a311

View all
  • Wave Mesh

    Wave Mesh

    198
  • Route Globe

    Route Globe

    162
  • Glass Tiles

    Glass Tiles

    151
  • Orbit Ring Stats

    Orbit Ring Stats

    63
  • Glyph Swell

    Glyph Swell

    60
  • Ask Bar

    Ask Bar

    51
  • Fan Deck Card

    Fan Deck Card

    43
  • Intent Label

    Intent Label

    41

More in Buttons

View all
  • Hero Button

    Hero Button

    21
  • Eclipse Button

    Eclipse Button

    9
  • Button

    Button

    141
  • Button

    Button

    19
  • Texture Button

    Texture Button

    111
  • HeroUI Toggle Button

    HeroUI Toggle Button

  • Random Letter Swap CTA Buttons

    Random Letter Swap CTA Buttons

    64
  • Water Ripple Button

    Water Ripple Button

    4