{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-orbit",
  "type": "registry:component",
  "title": "Button Orbit",
  "description": "Glowing particles circle the button on two tilted orbits, passing in front of and behind the face with real depth. Hovering spins them up, and a click flings them outward before they settle back.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "particles",
    "orbit",
    "3d",
    "launch",
    "glow"
  ],
  "docs": "https://hyperblur.dev/effects/button-orbit",
  "files": [
    {
      "path": "registry/hyperblur/button-orbit.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-orbit.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonOrbitProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\"> {\n  accent?: string;\n  particles?: number;\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n\nconst css = `\n.hb-xa5 {\n  --hb-xa5-c: #ffc857;\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  margin: 0;\n  padding: 0;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  line-height: 1;\n  color: #ededed;\n  background: transparent;\n  border: 0;\n  border-radius: 14px;\n  cursor: pointer;\n  isolation: isolate;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-xa5 *, .hb-xa5 *::before, .hb-xa5 *::after { box-sizing: border-box; }\n.hb-xa5[data-size=\"sm\"] { font-size: 13px; }\n.hb-xa5[data-size=\"lg\"] { font-size: 17px; }\n.hb-xa5:focus-visible { outline: none; }\n.hb-xa5:focus-visible .hb-xa5-face { box-shadow: 0 0 0 2px #0a0a0a, 0 0 0 4px var(--hb-xa5-c); }\n.hb-xa5:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xa5-face {\n  position: relative;\n  z-index: 2;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.6em;\n  padding: 0.9em 1.5em;\n  border-radius: inherit;\n  white-space: nowrap;\n  background:\n    radial-gradient(120% 140% at 50% 120%, color-mix(in srgb, var(--hb-xa5-c) 22%, transparent), transparent 60%),\n    linear-gradient(180deg, #1d1b17, #12110f);\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.08),\n    inset 0 0 0 1px color-mix(in srgb, var(--hb-xa5-c) 22%, #2a2a2a),\n    0 14px 30px -18px color-mix(in srgb, var(--hb-xa5-c) 60%, transparent);\n  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;\n}\n.hb-xa5:hover:not(:disabled) .hb-xa5-face {\n  box-shadow:\n    inset 0 1px 0 rgba(255, 255, 255, 0.1),\n    inset 0 0 0 1px color-mix(in srgb, var(--hb-xa5-c) 45%, #2a2a2a),\n    0 16px 36px -16px color-mix(in srgb, var(--hb-xa5-c) 75%, transparent);\n}\n.hb-xa5:active:not(:disabled) .hb-xa5-face { transform: scale(0.96); }\n.hb-xa5-ico { width: 1.1em; height: 1.1em; color: var(--hb-xa5-c); flex: none; transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xa5:hover:not(:disabled) .hb-xa5-ico { transform: translate(1px, -1px) rotate(-8deg); }\n.hb-xa5-orb {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: var(--hb-xa5-s);\n  height: var(--hb-xa5-s);\n  margin: calc(var(--hb-xa5-s) / -2) 0 0 calc(var(--hb-xa5-s) / -2);\n  border-radius: 50%;\n  pointer-events: none;\n  background: radial-gradient(circle, #fff 0%, var(--hb-xa5-c) 45%, color-mix(in srgb, var(--hb-xa5-c) 0%, transparent) 72%);\n  will-change: transform, opacity;\n  z-index: 1;\n}\n.hb-xa5-orb[data-front=\"true\"] { z-index: 3; }\n`;\n\nfunction hash(n: number) {\n  let h = Math.imul(n + 3, 2654435761);\n  h = Math.imul(h ^ (h >>> 15), 2246822519);\n  h = Math.imul(h ^ (h >>> 13), 3266489917);\n  return ((h ^ (h >>> 16)) >>> 0) / 4294967295;\n}\n\nfunction Rocket() {\n  return (\n    <svg className=\"hb-xa5-ico\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\">\n      <path d=\"M11.8 3.2c2.3-.6 4.3-.5 5 .1.6.7.7 2.7.1 5-.6 2.4-2.2 4.6-4.6 6.2l-.6 2.7-2.6-1.5-2.8-2.8-1.5-2.6 2.7-.6c1.6-2.4 3.8-4 6.3-4.5Z\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\" />\n      <circle cx=\"12.6\" cy=\"7.4\" r=\"1.4\" fill=\"currentColor\" />\n      <path d=\"M5.2 12.6c-1.3.4-2 1.9-2 3.9 2 0 3.5-.7 3.9-2\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nexport function ButtonOrbit({\n  children = \"Launch project\",\n  accent = \"#ffc857\",\n  particles = 12,\n  size = \"md\",\n  type = \"button\",\n  disabled = false,\n  className = \"\",\n  style,\n  onClick,\n  onPointerEnter,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  ...rest\n}: ButtonOrbitProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const orbs = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const ctl = React.useRef({ hot: false, burst: 0, kick: () => {} });\n  const n = Math.max(0, Math.min(24, Math.round(particles)));\n\n  const seeds = React.useMemo(\n    () =>\n      Array.from({ length: n }, (_, i) => ({\n        ring: i % 2,\n        phase: (i / Math.max(1, n)) * Math.PI * 2 + hash(i) * 0.6,\n        speed: 0.7 + hash(i + 20) * 0.6,\n        rad: 1 + (hash(i + 40) - 0.5) * 0.16,\n        size: 4 + hash(i + 60) * 5,\n      })),\n    [n],\n  );\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const state = ctl.current;\n    let raf = 0;\n    let last = 0;\n    let t = 0;\n    let rate = 0.35;\n    let spread = 0;\n    let visible = true;\n\n    function draw() {\n      const w = el!.offsetWidth;\n      const h = el!.offsetHeight;\n      const rx = w / 2 + 18;\n      const ry = h / 2 + 10;\n      for (let i = 0; i < seeds.length; i++) {\n        const node = orbs.current[i];\n        if (!node) continue;\n        const s = seeds[i];\n        const tilt = s.ring ? -0.22 : 0.18;\n        const a = s.phase + t * s.speed * (s.ring ? -1 : 1);\n        const ex = Math.cos(a) * rx * s.rad * (1 + spread * 1.6);\n        const ey = Math.sin(a) * ry * 0.55 * s.rad * (1 + spread * 2.4);\n        const x = ex * Math.cos(tilt) - ey * Math.sin(tilt);\n        const y = ex * Math.sin(tilt) + ey * Math.cos(tilt);\n        const depth = Math.sin(a) * (s.ring ? -1 : 1);\n        const sc = (0.7 + depth * 0.3) * (1 - spread * 0.4);\n        const op = Math.max(0, (0.55 + depth * 0.45) * (1 - spread * 0.9));\n        node.style.transform = `translate(${x.toFixed(2)}px, ${y.toFixed(2)}px) scale(${sc.toFixed(3)})`;\n        node.style.opacity = op.toFixed(3);\n        node.dataset.front = depth > 0 ? \"true\" : \"false\";\n        node.style.setProperty(\"--hb-xa5-s\", `${s.size.toFixed(1)}px`);\n      }\n    }\n\n    function step(now: number) {\n      raf = 0;\n      if (!visible) return;\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 0.016;\n      last = now;\n      const target = state.hot ? 2.4 : 0.45;\n      rate += (target - rate) * Math.min(1, dt * 4);\n      if (state.burst > 0) {\n        state.burst = Math.max(0, state.burst - dt * 1.5);\n        const b = state.burst;\n        spread = b > 0.5 ? (1 - b) * 2 : b * 2;\n      } else spread = 0;\n      t += dt * rate;\n      draw();\n      raf = requestAnimationFrame(step);\n    }\n\n    function start() {\n      if (mq.matches) {\n        spread = 0;\n        draw();\n        return;\n      }\n      last = 0;\n      if (!raf && visible) raf = requestAnimationFrame(step);\n    }\n\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible) start();\n      else {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n    });\n    io.observe(el);\n    const onMq = () => {\n      cancelAnimationFrame(raf);\n      raf = 0;\n      start();\n    };\n    mq.addEventListener(\"change\", onMq);\n    state.kick = start;\n    draw();\n    start();\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      mq.removeEventListener(\"change\", onMq);\n    };\n  }, [seeds]);\n\n  function heat(v: boolean) {\n    ctl.current.hot = v;\n    ctl.current.kick();\n  }\n\n  const vars = { \"--hb-xa5-c\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-orbit\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        className={`hb-xa5 ${className}`}\n        style={vars}\n        data-size={size}\n        disabled={disabled}\n        onClick={(e) => {\n          ctl.current.burst = 1;\n          ctl.current.kick();\n          onClick?.(e);\n        }}\n        onPointerEnter={(e) => {\n          heat(true);\n          onPointerEnter?.(e);\n        }}\n        onPointerLeave={(e) => {\n          heat(false);\n          onPointerLeave?.(e);\n        }}\n        onFocus={(e) => {\n          heat(true);\n          onFocus?.(e);\n        }}\n        onBlur={(e) => {\n          heat(false);\n          onBlur?.(e);\n        }}\n        {...rest}\n      >\n        {seeds.map((s, i) => (\n          <span\n            className=\"hb-xa5-orb\"\n            key={i}\n            aria-hidden=\"true\"\n            ref={(node) => {\n              orbs.current[i] = node;\n            }}\n            style={{ \"--hb-xa5-s\": `${s.size.toFixed(1)}px`, opacity: 0 } as React.CSSProperties}\n          />\n        ))}\n        <span className=\"hb-xa5-face\">\n          <Rocket />\n          {children}\n        </span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}