{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-goo",
  "type": "registry:component",
  "title": "Button Goo",
  "description": "Droplets bud off the pill on hover and stay attached through a liquid goo filter, while a blob bulges out on the side nearest the cursor. A click splashes them outward before they flow back.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "goo",
    "liquid",
    "blob",
    "svg filter",
    "metaball"
  ],
  "docs": "https://hyperblur.dev/effects/button-goo",
  "files": [
    {
      "path": "registry/hyperblur/button-goo.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-goo.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonGooProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\"> {\n  accent?: string;\n  blobs?: number;\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n\nconst css = `\n.hb-xa3 {\n  --hb-xa3-c: #7c5cff;\n  --hb-xa3-px: 50%;\n  --hb-xa3-py: 50%;\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.95em 1.9em;\n  font: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  line-height: 1;\n  color: #fff;\n  background: transparent;\n  border: 0;\n  border-radius: 999px;\n  cursor: pointer;\n  isolation: isolate;\n  user-select: none;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-xa3 *, .hb-xa3 *::before, .hb-xa3 *::after { box-sizing: border-box; }\n.hb-xa3[data-size=\"sm\"] { font-size: 13px; }\n.hb-xa3[data-size=\"lg\"] { font-size: 17px; }\n.hb-xa3:focus-visible { outline: 2px solid var(--hb-xa3-c); outline-offset: 5px; }\n.hb-xa3:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xa3-svg { position: absolute; width: 0; height: 0; overflow: hidden; }\n.hb-xa3-goo {\n  position: absolute;\n  inset: -28px;\n  z-index: -1;\n  pointer-events: none;\n}\n.hb-xa3-pill {\n  position: absolute;\n  inset: 28px;\n  border-radius: 999px;\n  background: var(--hb-xa3-c);\n  transition: inset 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-xa3:active:not(:disabled) .hb-xa3-pill { inset: 30px 32px; }\n.hb-xa3-blob {\n  position: absolute;\n  left: var(--hb-xa3-bx);\n  top: var(--hb-xa3-by);\n  width: var(--hb-xa3-bs);\n  height: var(--hb-xa3-bs);\n  margin: calc(var(--hb-xa3-bs) / -2) 0 0 calc(var(--hb-xa3-bs) / -2);\n  border-radius: 50%;\n  background: var(--hb-xa3-c);\n  transform: translate(0, 0) scale(0.6);\n  transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);\n  transition-delay: var(--hb-xa3-bd);\n}\n.hb-xa3:hover:not(:disabled) .hb-xa3-blob,\n.hb-xa3:focus-visible .hb-xa3-blob {\n  transform: translate(var(--hb-xa3-dx), var(--hb-xa3-dy)) scale(1);\n  animation: hb-xa3-bob 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;\n  animation-delay: calc(var(--hb-xa3-bd) + 0.7s);\n}\n.hb-xa3.hb-xa3[data-pop=\"a\"] .hb-xa3-blob { animation: hb-xa3-pa 0.75s cubic-bezier(0.2, 0.9, 0.3, 1.2); }\n.hb-xa3.hb-xa3[data-pop=\"b\"] .hb-xa3-blob { animation: hb-xa3-pb 0.75s cubic-bezier(0.2, 0.9, 0.3, 1.2); }\n.hb-xa3-cursor {\n  position: absolute;\n  left: var(--hb-xa3-px);\n  top: var(--hb-xa3-py);\n  width: 30px;\n  height: 30px;\n  margin: -15px 0 0 -15px;\n  border-radius: 50%;\n  background: var(--hb-xa3-c);\n  transform: scale(0);\n  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);\n}\n.hb-xa3[data-near=\"true\"] .hb-xa3-cursor { transform: scale(1); }\n.hb-xa3-shine {\n  position: absolute;\n  inset: 0;\n  z-index: -1;\n  border-radius: inherit;\n  pointer-events: none;\n  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -8px 14px rgba(0, 0, 0, 0.18);\n}\n.hb-xa3-label { display: inline-flex; align-items: center; gap: 0.5em; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }\n.hb-xa3-shadow {\n  position: absolute;\n  left: 10%;\n  right: 10%;\n  bottom: -10px;\n  height: 18px;\n  z-index: -2;\n  border-radius: 50%;\n  background: var(--hb-xa3-c);\n  filter: blur(14px);\n  opacity: 0.55;\n  pointer-events: none;\n}\n@keyframes hb-xa3-bob {\n  from { transform: translate(var(--hb-xa3-dx), var(--hb-xa3-dy)) scale(1); }\n  to { transform: translate(calc(var(--hb-xa3-dx) * 0.35), calc(var(--hb-xa3-dy) * 0.35)) scale(0.75); }\n}\n@keyframes hb-xa3-pa {\n  0% { transform: translate(0, 0) scale(0.6); }\n  45% { transform: translate(calc(var(--hb-xa3-dx) * 2.3), calc(var(--hb-xa3-dy) * 2.3)) scale(0.85); }\n  100% { transform: translate(var(--hb-xa3-dx), var(--hb-xa3-dy)) scale(1); }\n}\n@keyframes hb-xa3-pb {\n  0% { transform: translate(0, 0) scale(0.6); }\n  45% { transform: translate(calc(var(--hb-xa3-dx) * 2.3), calc(var(--hb-xa3-dy) * 2.3)) scale(0.85); }\n  100% { transform: translate(var(--hb-xa3-dx), var(--hb-xa3-dy)) scale(1); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-xa3-pill, .hb-xa3-blob, .hb-xa3-cursor { transition: none; }\n  .hb-xa3:hover:not(:disabled) .hb-xa3-blob, .hb-xa3:focus-visible .hb-xa3-blob,\n  .hb-xa3.hb-xa3[data-pop] .hb-xa3-blob { animation: none; transform: translate(0, 0) scale(0.6); }\n  .hb-xa3[data-near=\"true\"] .hb-xa3-cursor { transform: scale(0); }\n}\n`;\n\nfunction hash(n: number) {\n  let h = (n + 1) * 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\nexport function ButtonGoo({\n  children = \"Join the beta\",\n  accent = \"#7c5cff\",\n  blobs = 7,\n  size = \"md\",\n  type = \"button\",\n  disabled = false,\n  className = \"\",\n  style,\n  onClick,\n  onPointerMove,\n  onPointerLeave,\n  ...rest\n}: ButtonGooProps) {\n  const raw = React.useId();\n  const id = `hb-xa3-f${raw.replace(/[^a-zA-Z0-9]/g, \"\")}`;\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const [pop, setPop] = React.useState<\"a\" | \"b\" | undefined>(undefined);\n  const [near, setNear] = React.useState(false);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n  React.useEffect(() => () => clearTimeout(timer.current), []);\n  const count = Math.max(0, Math.min(14, Math.round(blobs)));\n\n  const list = Array.from({ length: count }, (_, i) => {\n    const t = (i + 0.5) / Math.max(1, count);\n    const top = i % 2 === 0;\n    const bx = 14 + t * 72;\n    const by = top ? 34 : 66;\n    const lift = 10 + hash(i) * 12;\n    const side = t < 0.12 ? -1 : t > 0.88 ? 1 : 0;\n    return {\n      \"--hb-xa3-bx\": `${bx.toFixed(1)}%`,\n      \"--hb-xa3-by\": `${by.toFixed(1)}%`,\n      \"--hb-xa3-bs\": `${(12 + hash(i + 40) * 12).toFixed(1)}px`,\n      \"--hb-xa3-dx\": `${(side * lift + (hash(i + 7) - 0.5) * 8).toFixed(1)}px`,\n      \"--hb-xa3-dy\": `${((top ? -1 : 1) * lift).toFixed(1)}px`,\n      \"--hb-xa3-bd\": `${(hash(i + 90) * 0.12).toFixed(3)}s`,\n    } as React.CSSProperties;\n  });\n\n  function follow(e: React.PointerEvent<HTMLButtonElement>) {\n    const el = ref.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const fx = (e.clientX - r.left) / r.width - 0.5;\n    const fy = (e.clientY - r.top) / r.height - 0.5;\n    const ox = 50 + fx * 100 * 1.12;\n    const oy = 50 + fy * 100 * 1.9;\n    const gw = r.width + 56;\n    const gh = r.height + 56;\n    const px = 28 + (ox / 100) * r.width;\n    const py = 28 + (oy / 100) * r.height;\n    el.style.setProperty(\"--hb-xa3-px\", `${((px / gw) * 100).toFixed(2)}%`);\n    el.style.setProperty(\"--hb-xa3-py\", `${((py / gh) * 100).toFixed(2)}%`);\n    if (!near) setNear(true);\n  }\n\n  const vars = { \"--hb-xa3-c\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-button-goo\" precedence=\"default\">{css}</style>\n      <button\n        ref={ref}\n        type={type}\n        className={`hb-xa3 ${className}`}\n        style={vars}\n        data-size={size}\n        data-pop={pop}\n        data-near={near || undefined}\n        disabled={disabled}\n        onClick={(e) => {\n          setPop((p) => (p === \"a\" ? \"b\" : \"a\"));\n          clearTimeout(timer.current);\n          timer.current = setTimeout(() => setPop(undefined), 780);\n          onClick?.(e);\n        }}\n        onPointerMove={(e) => {\n          follow(e);\n          onPointerMove?.(e);\n        }}\n        onPointerLeave={(e) => {\n          setNear(false);\n          onPointerLeave?.(e);\n        }}\n        {...rest}\n      >\n        <svg className=\"hb-xa3-svg\" aria-hidden=\"true\" focusable=\"false\">\n          <defs>\n            <filter id={id} x=\"-20%\" y=\"-50%\" width=\"140%\" height=\"200%\" colorInterpolationFilters=\"sRGB\">\n              <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"6\" result=\"b\" />\n              <feColorMatrix in=\"b\" mode=\"matrix\" values=\"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 20 -8\" />\n            </filter>\n          </defs>\n        </svg>\n        <span className=\"hb-xa3-shadow\" aria-hidden=\"true\" />\n        <span className=\"hb-xa3-goo\" style={{ filter: `url(#${id})` }} aria-hidden=\"true\">\n          <span className=\"hb-xa3-pill\" />\n          {list.map((v, i) => (\n            <span className=\"hb-xa3-blob\" style={v} key={i} />\n          ))}\n          <span className=\"hb-xa3-cursor\" />\n        </span>\n        <span className=\"hb-xa3-shine\" aria-hidden=\"true\" />\n        <span className=\"hb-xa3-label\">{children}</span>\n      </button>\n    </>\n  );\n}\n"
    }
  ]
}