{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-magnetic-pill",
  "type": "registry:component",
  "title": "Button Magnetic Pill",
  "description": "A pill that is pulled toward the cursor before you reach it: the body stretches like liquid along the pointer direction, the label trails with parallax and a highlight sits on the near side. It snaps back with an elastic overshoot.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "magnetic",
    "pointer",
    "elastic",
    "stretch",
    "cta"
  ],
  "docs": "https://hyperblur.dev/effects/button-magnetic-pill",
  "files": [
    {
      "path": "registry/hyperblur/button-magnetic-pill.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-magnetic-pill.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonMagneticPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n  radius?: number;\n  strength?: number;\n  stretch?: number;\n  variant?: \"light\" | \"accent\" | \"dark\";\n  accent?: string;\n  arrow?: boolean;\n}\n\nconst css = `\n.hb-xb11 {\n  --hb-xb11-c: #2f7bff;\n  --hb-xb11-tx: 0px;\n  --hb-xb11-ty: 0px;\n  --hb-xb11-a: 0deg;\n  --hb-xb11-k: 0;\n  --hb-xb11-gx: 50%;\n  --hb-xb11-gy: 0%;\n  --hb-xb11-gl: 0;\n  --hb-xb11-bg: linear-gradient(180deg, #ffffff 0%, #ececec 100%);\n  --hb-xb11-fg: #0a0a0a;\n  --hb-xb11-sh: 0 14px 30px -14px rgba(255, 255, 255, 0.35), 0 4px 12px -4px rgba(0, 0, 0, 0.6);\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  height: 46px;\n  margin: 0;\n  padding: 0 24px;\n  border: 0;\n  background: transparent;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  letter-spacing: -0.01em;\n  color: var(--hb-xb11-fg);\n  cursor: pointer;\n  isolation: isolate;\n  -webkit-tap-highlight-color: transparent;\n  transform: translate(var(--hb-xb11-tx), var(--hb-xb11-ty));\n  transition: transform 0.75s cubic-bezier(0.2, 1.65, 0.38, 1);\n}\n.hb-xb11 *, .hb-xb11 *::before, .hb-xb11 *::after { box-sizing: border-box; }\n.hb-xb11[data-variant=\"accent\"] {\n  --hb-xb11-bg: linear-gradient(180deg, color-mix(in srgb, var(--hb-xb11-c) 82%, #fff) 0%, var(--hb-xb11-c) 60%, color-mix(in srgb, var(--hb-xb11-c) 88%, #000) 100%);\n  --hb-xb11-fg: #ffffff;\n  --hb-xb11-sh: 0 14px 30px -12px var(--hb-xb11-c), 0 4px 12px -4px rgba(0, 0, 0, 0.6);\n}\n.hb-xb11[data-variant=\"dark\"] {\n  --hb-xb11-bg: linear-gradient(180deg, #262626 0%, #171717 100%);\n  --hb-xb11-fg: #ededed;\n  --hb-xb11-sh: 0 0 0 1px #303030, 0 14px 30px -14px rgba(0, 0, 0, 0.95);\n}\n.hb-xb11[data-live=\"true\"] { transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xb11-skin {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: 999px;\n  background: var(--hb-xb11-bg);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -1px 0 rgba(0, 0, 0, 0.12), var(--hb-xb11-sh);\n  transform: rotate(var(--hb-xb11-a)) scale(calc(1 + var(--hb-xb11-k)), calc(1 - var(--hb-xb11-k) * 0.38)) rotate(calc(var(--hb-xb11-a) * -1));\n  transition: transform 0.8s cubic-bezier(0.2, 1.8, 0.35, 1), box-shadow 0.3s ease;\n  overflow: hidden;\n}\n.hb-xb11[data-variant=\"dark\"] .hb-xb11-skin { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), var(--hb-xb11-sh); }\n.hb-xb11[data-live=\"true\"] .hb-xb11-skin { transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xb11-skin::after {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  background: radial-gradient(70px 46px at var(--hb-xb11-gx) var(--hb-xb11-gy), rgba(255, 255, 255, 0.55), transparent 70%);\n  opacity: var(--hb-xb11-gl);\n  mix-blend-mode: soft-light;\n  transition: opacity 0.4s ease;\n}\n.hb-xb11-label {\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  white-space: nowrap;\n  transform: translate(calc(var(--hb-xb11-tx) * 0.45), calc(var(--hb-xb11-ty) * 0.45));\n  transition: transform 0.9s cubic-bezier(0.2, 1.65, 0.38, 1);\n}\n.hb-xb11[data-live=\"true\"] .hb-xb11-label { transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-xb11-arrow { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xb11:hover .hb-xb11-arrow { transform: translateX(3px); }\n.hb-xb11:active:not(:disabled) .hb-xb11-skin { transform: rotate(var(--hb-xb11-a)) scale(calc(0.95 + var(--hb-xb11-k)), calc(0.92 - var(--hb-xb11-k) * 0.38)) rotate(calc(var(--hb-xb11-a) * -1)); transition-duration: 0.12s; }\n.hb-xb11:focus-visible { outline: none; }\n.hb-xb11:focus-visible .hb-xb11-skin { outline: 2px solid var(--hb-xb11-c); outline-offset: 3px; }\n.hb-xb11[data-variant=\"accent\"]:focus-visible .hb-xb11-skin { outline-color: #ffffff; }\n.hb-xb11:disabled { cursor: not-allowed; opacity: 0.45; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xb11, .hb-xb11 * { transition-duration: 0.01s !important; }\n}\n`;\n\nexport function ButtonMagneticPill({\n  children = \"Get early access\",\n  radius = 110,\n  strength = 0.35,\n  stretch = 0.22,\n  variant = \"light\",\n  accent = \"#2f7bff\",\n  arrow = true,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  ...rest\n}: ButtonMagneticPillProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el || disabled) return;\n    if (!window.matchMedia(\"(hover: hover) and (pointer: fine)\").matches) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let raf = 0;\n    let px = 0;\n    let py = 0;\n    let live = false;\n    const reset = () => {\n      live = false;\n      el.dataset.live = \"false\";\n      el.style.setProperty(\"--hb-xb11-tx\", \"0px\");\n      el.style.setProperty(\"--hb-xb11-ty\", \"0px\");\n      el.style.setProperty(\"--hb-xb11-k\", \"0\");\n      el.style.setProperty(\"--hb-xb11-gl\", \"0\");\n    };\n    const frame = () => {\n      raf = 0;\n      const r = el.getBoundingClientRect();\n      const tx = parseFloat(el.style.getPropertyValue(\"--hb-xb11-tx\")) || 0;\n      const ty = parseFloat(el.style.getPropertyValue(\"--hb-xb11-ty\")) || 0;\n      const cx = r.left - tx + r.width / 2;\n      const cy = r.top - ty + r.height / 2;\n      const dx = px - cx;\n      const dy = py - cy;\n      const ex = Math.max(0, Math.abs(dx) - r.width / 2);\n      const ey = Math.max(0, Math.abs(dy) - r.height / 2);\n      const edge = Math.hypot(ex, ey);\n      if (edge > radius) {\n        if (live) reset();\n        return;\n      }\n      const t = 1 - edge / radius;\n      const f = t * t * (3 - 2 * t);\n      const reach = Math.min(1, Math.hypot(dx, dy) / (r.width / 2 + radius));\n      live = true;\n      el.dataset.live = \"true\";\n      el.style.setProperty(\"--hb-xb11-tx\", `${(dx * strength * f).toFixed(2)}px`);\n      el.style.setProperty(\"--hb-xb11-ty\", `${(dy * strength * f * 1.2).toFixed(2)}px`);\n      el.style.setProperty(\"--hb-xb11-a\", `${((Math.atan2(dy, dx) * 180) / Math.PI).toFixed(1)}deg`);\n      el.style.setProperty(\"--hb-xb11-k\", (reach * f * stretch).toFixed(4));\n      const gx = Math.max(0, Math.min(100, ((px - (cx - r.width / 2)) / r.width) * 100));\n      const gy = Math.max(0, Math.min(100, ((py - (cy - r.height / 2)) / r.height) * 100));\n      el.style.setProperty(\"--hb-xb11-gx\", `${gx.toFixed(1)}%`);\n      el.style.setProperty(\"--hb-xb11-gy\", `${gy.toFixed(1)}%`);\n      el.style.setProperty(\"--hb-xb11-gl\", f.toFixed(3));\n    };\n    const onMove = (e: PointerEvent) => {\n      if (e.pointerType !== \"mouse\" && e.pointerType !== \"pen\") return;\n      px = e.clientX;\n      py = e.clientY;\n      if (!raf) raf = requestAnimationFrame(frame);\n    };\n    const onLeave = () => {\n      if (raf) cancelAnimationFrame(raf);\n      raf = 0;\n      reset();\n    };\n    window.addEventListener(\"pointermove\", onMove, { passive: true });\n    document.documentElement.addEventListener(\"pointerleave\", onLeave);\n    window.addEventListener(\"blur\", onLeave);\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      window.removeEventListener(\"pointermove\", onMove);\n      document.documentElement.removeEventListener(\"pointerleave\", onLeave);\n      window.removeEventListener(\"blur\", onLeave);\n      reset();\n    };\n  }, [radius, strength, stretch, disabled]);\n\n  return (\n    <button\n      ref={ref}\n      type={type}\n      disabled={disabled}\n      className={`hb-xb11 ${className}`.trim()}\n      data-variant={variant}\n      data-live=\"false\"\n      style={{ \"--hb-xb11-c\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-button-magnetic-pill\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xb11-skin\" aria-hidden=\"true\" />\n      <span className=\"hb-xb11-label\">\n        {children}\n        {arrow && (\n          <svg className=\"hb-xb11-arrow\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n            <path d=\"M5 12h13M13 6l6 6-6 6\" />\n          </svg>\n        )}\n      </span>\n    </button>\n  );\n}\n"
    }
  ]
}