{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-speed-dial",
  "type": "registry:component",
  "title": "Button Speed Dial",
  "description": "A floating action button that fans its actions out on an arc or stacks them upward, with a staggered spring, a dimming halo and labels. The plus turns into a close mark.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "fab",
    "speed dial",
    "floating action",
    "menu",
    "mobile"
  ],
  "docs": "https://hyperblur.dev/effects/button-speed-dial",
  "files": [
    {
      "path": "registry/hyperblur/button-speed-dial.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-speed-dial.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonSpeedDialAction {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n}\n\nexport interface ButtonSpeedDialProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  actions?: ButtonSpeedDialAction[];\n  layout?: \"arc\" | \"stack\";\n  startAngle?: number;\n  endAngle?: number;\n  radius?: number;\n  labelSide?: \"left\" | \"right\";\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  onSelect?: (id: string) => void;\n  label?: string;\n  accent?: string;\n  scrim?: boolean;\n}\n\nconst css = `\n.hb-xb8 {\n  --hb-xb8-c: #2f7bff;\n  position: relative;\n  display: inline-grid;\n  place-items: center;\n  width: 56px;\n  height: 56px;\n  box-sizing: border-box;\n  font-family: inherit;\n  color: #ededed;\n}\n.hb-xb8 *, .hb-xb8 *::before, .hb-xb8 *::after { box-sizing: border-box; }\n.hb-xb8-scrim {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: var(--hb-xb8-sw, 260px);\n  height: var(--hb-xb8-sw, 260px);\n  margin: calc(var(--hb-xb8-sw, 260px) / -2);\n  border-radius: 50%;\n  background: radial-gradient(circle, rgba(10, 10, 10, 0.88) 0%, rgba(10, 10, 10, 0.6) 45%, transparent 70%);\n  opacity: 0;\n  transform: scale(0.4);\n  pointer-events: none;\n  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-xb8[data-open=\"true\"] .hb-xb8-scrim { opacity: 1; transform: none; }\n.hb-xb8-fab {\n  position: relative;\n  z-index: 2;\n  width: 56px;\n  height: 56px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  display: grid;\n  place-items: center;\n  color: #fff;\n  font: inherit;\n  cursor: pointer;\n  background: radial-gradient(120% 120% at 30% 15%, color-mix(in srgb, var(--hb-xb8-c) 70%, #fff) 0%, var(--hb-xb8-c) 45%, color-mix(in srgb, var(--hb-xb8-c) 75%, #000) 100%);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 12px 28px -10px var(--hb-xb8-c), 0 4px 10px -2px rgba(0, 0, 0, 0.6);\n  -webkit-tap-highlight-color: transparent;\n  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.35s ease, box-shadow 0.35s ease;\n}\n.hb-xb8-fab:hover { transform: translateY(-1px) scale(1.03); }\n.hb-xb8-fab:active { transform: scale(0.94); }\n.hb-xb8[data-open=\"true\"] .hb-xb8-fab { background: radial-gradient(120% 120% at 30% 15%, #3a3a3a 0%, #1f1f1f 60%, #151515 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 1px #333, 0 12px 28px -10px rgba(0, 0, 0, 0.9); }\n.hb-xb8-fab:focus-visible { outline: 2px solid var(--hb-xb8-c); outline-offset: 4px; }\n.hb-xb8-fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-xb8[data-open=\"true\"] .hb-xb8-fab svg { transform: rotate(135deg); }\n.hb-xb8-list { position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: 0; padding: 0; list-style: none; z-index: 1; }\n.hb-xb8-li { position: absolute; left: 0; top: 0; }\n.hb-xb8-act {\n  position: absolute;\n  left: -21px;\n  top: -21px;\n  width: 42px;\n  height: 42px;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  border-radius: 50%;\n  display: grid;\n  place-items: center;\n  color: #ededed;\n  font: inherit;\n  cursor: pointer;\n  background: linear-gradient(180deg, #232323, #181818);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 0 1px #2e2e2e, 0 10px 20px -10px rgba(0, 0, 0, 0.95);\n  opacity: 0;\n  visibility: hidden;\n  transform: translate(0, 0) scale(0.3);\n  transition: transform 0.38s cubic-bezier(0.55, 0, 0.3, 1) var(--hb-xb8-out, 0s), opacity 0.2s ease var(--hb-xb8-out, 0s), visibility 0s linear calc(var(--hb-xb8-out, 0s) + 0.38s), background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-xb8[data-open=\"true\"] .hb-xb8-act {\n  opacity: 1;\n  visibility: visible;\n  transform: translate(var(--hb-xb8-x), var(--hb-xb8-y)) scale(1);\n  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) var(--hb-xb8-in, 0s), opacity 0.2s ease var(--hb-xb8-in, 0s), visibility 0s, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;\n}\n.hb-xb8-act:hover, .hb-xb8-act:focus-visible { color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--hb-xb8-c) 55%, #222), color-mix(in srgb, var(--hb-xb8-c) 35%, #161616)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 1px color-mix(in srgb, var(--hb-xb8-c) 60%, transparent), 0 10px 22px -10px var(--hb-xb8-c); outline: none; }\n.hb-xb8-act svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }\n.hb-xb8-tip {\n  position: absolute;\n  top: 50%;\n  white-space: nowrap;\n  padding: 5px 9px;\n  border-radius: 7px;\n  font-size: 12px;\n  font-weight: 550;\n  color: #ededed;\n  background: #1b1b1b;\n  box-shadow: 0 0 0 1px #2c2c2c, 0 8px 18px -8px rgba(0, 0, 0, 0.9);\n  pointer-events: none;\n  opacity: 0;\n  transform: translateY(-50%) translateX(var(--hb-xb8-tx, 4px));\n  transition: opacity 0.18s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-xb8-tip[data-side=\"left\"] { right: calc(100% + 9px); --hb-xb8-tx: 4px; }\n.hb-xb8-tip[data-side=\"right\"] { left: calc(100% + 9px); --hb-xb8-tx: -4px; }\n.hb-xb8-tip[data-side=\"top\"] { bottom: calc(100% + 8px); top: auto; left: 50%; transform: translateX(-50%) translateY(4px); }\n.hb-xb8-act:hover .hb-xb8-tip, .hb-xb8-act:focus-visible .hb-xb8-tip { opacity: 1; transform: translateY(-50%); }\n.hb-xb8-act:hover .hb-xb8-tip[data-side=\"top\"], .hb-xb8-act:focus-visible .hb-xb8-tip[data-side=\"top\"] { transform: translateX(-50%); }\n.hb-xb8[data-layout=\"stack\"][data-open=\"true\"] .hb-xb8-tip { opacity: 1; transform: translateY(-50%); transition-delay: calc(var(--hb-xb8-in, 0s) + 0.12s); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xb8 *, .hb-xb8-act, .hb-xb8[data-open=\"true\"] .hb-xb8-act { transition-duration: 0.01s !important; transition-delay: 0s !important; }\n}\n`;\n\nconst ico = (d: string) => (\n  <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n    <path d={d} />\n  </svg>\n);\n\nconst defaultActions: ButtonSpeedDialAction[] = [\n  { id: \"note\", label: \"New note\", icon: ico(\"M14 3.5H7.5c-1 0-2 .9-2 2v13c0 1.1 1 2 2 2h9c1.1 0 2-.9 2-2V8zM14 3.5V8h4.5M9 13h6M9 16.5h4\") },\n  { id: \"photo\", label: \"Take photo\", icon: ico(\"M4 8.5c0-1 .8-1.8 1.8-1.8h2l1.4-2h5.6l1.4 2h2c1 0 1.8.8 1.8 1.8v9c0 1-.8 1.8-1.8 1.8H5.8c-1 0-1.8-.8-1.8-1.8zM12 16.3a3.3 3.3 0 1 0 0-6.6 3.3 3.3 0 0 0 0 6.6z\") },\n  { id: \"voice\", label: \"Voice memo\", icon: ico(\"M12 3.5a2.8 2.8 0 0 0-2.8 2.8v5.4a2.8 2.8 0 0 0 5.6 0V6.3A2.8 2.8 0 0 0 12 3.5zM6.5 11.5a5.5 5.5 0 0 0 11 0M12 17v3.5\") },\n  { id: \"upload\", label: \"Upload file\", icon: ico(\"M12 15.5V4.5M7.5 9L12 4.5 16.5 9M5 15v2.8c0 1 .8 1.7 1.7 1.7h10.6c1 0 1.7-.8 1.7-1.7V15\") },\n];\n\nexport function ButtonSpeedDial({\n  actions = defaultActions,\n  layout = \"arc\",\n  startAngle = 90,\n  endAngle = 180,\n  radius = 82,\n  labelSide = \"left\",\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  onSelect,\n  label = \"Create\",\n  accent = \"#2f7bff\",\n  scrim = true,\n  className = \"\",\n  style,\n  ...rest\n}: ButtonSpeedDialProps) {\n  const id = React.useId();\n  const [inner, setInner] = React.useState(defaultOpen);\n  const isOpen = open ?? inner;\n  const root = React.useRef<HTMLDivElement>(null);\n  const fab = React.useRef<HTMLButtonElement>(null);\n  const refs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const focusFirst = React.useRef(false);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n\n  React.useEffect(() => {\n    if (!isOpen) return;\n    if (focusFirst.current) {\n      focusFirst.current = false;\n      refs.current[0]?.focus();\n    }\n    const onDown = (e: PointerEvent) => {\n      if (root.current && !root.current.contains(e.target as Node)) setOpen(false);\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [isOpen, setOpen]);\n\n  const n = actions.length;\n  const pos = actions.map((_, i) => {\n    if (layout === \"stack\") return { x: 0, y: -(i + 1) * 54 };\n    const t = n === 1 ? 0.5 : i / (n - 1);\n    const a = ((startAngle + (endAngle - startAngle) * t) * Math.PI) / 180;\n    return { x: Math.cos(a) * radius, y: -Math.sin(a) * radius };\n  });\n\n  const tipSide = (x: number, y: number): \"left\" | \"right\" | \"top\" => {\n    if (layout === \"stack\") return labelSide;\n    if (Math.abs(x) < 14 && y < 0) return \"top\";\n    return x <= 0 ? \"left\" : \"right\";\n  };\n\n  const onListKey = (e: React.KeyboardEvent) => {\n    const i = refs.current.findIndex((el) => el === document.activeElement);\n    if (e.key === \"Escape\") {\n      e.preventDefault();\n      setOpen(false);\n      fab.current?.focus();\n    } else if (e.key === \"ArrowUp\" || e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      refs.current[(i + 1) % n]?.focus();\n    } else if (e.key === \"ArrowDown\" || e.key === \"ArrowRight\") {\n      e.preventDefault();\n      if (i <= 0) fab.current?.focus();\n      else refs.current[i - 1]?.focus();\n    }\n  };\n\n  return (\n    <div\n      ref={root}\n      className={`hb-xb8 ${className}`.trim()}\n      data-open={isOpen ? \"true\" : \"false\"}\n      data-layout={layout}\n      style={{ \"--hb-xb8-c\": accent, \"--hb-xb8-sw\": `${Math.round((layout === \"stack\" ? n * 54 : radius) * 2 + 120)}px`, ...style } as React.CSSProperties}\n      onKeyDown={onListKey}\n      {...rest}\n    >\n      <style href=\"hb-button-speed-dial\" precedence=\"default\">{css}</style>\n      {scrim && <span className=\"hb-xb8-scrim\" aria-hidden=\"true\" />}\n      <ul id={`${id}-menu`} className=\"hb-xb8-list\" role=\"menu\" aria-label={label} aria-hidden={!isOpen}>\n        {actions.map((a, i) => (\n          <li key={a.id} className=\"hb-xb8-li\" role=\"none\">\n            <button\n              ref={(el) => {\n                refs.current[i] = el;\n              }}\n              type=\"button\"\n              role=\"menuitem\"\n              className=\"hb-xb8-act\"\n              tabIndex={isOpen ? 0 : -1}\n              aria-label={a.label}\n              style={\n                {\n                  \"--hb-xb8-x\": `${pos[i].x.toFixed(2)}px`,\n                  \"--hb-xb8-y\": `${pos[i].y.toFixed(2)}px`,\n                  \"--hb-xb8-in\": `${(i * 0.045).toFixed(3)}s`,\n                  \"--hb-xb8-out\": `${((n - 1 - i) * 0.03).toFixed(3)}s`,\n                } as React.CSSProperties\n              }\n              onClick={() => {\n                onSelect?.(a.id);\n                setOpen(false);\n                fab.current?.focus();\n              }}\n            >\n              {a.icon ?? ico(\"M12 5v14M5 12h14\")}\n              <span className=\"hb-xb8-tip\" data-side={tipSide(pos[i].x, pos[i].y)} aria-hidden=\"true\">\n                {a.label}\n              </span>\n            </button>\n          </li>\n        ))}\n      </ul>\n      <button\n        ref={fab}\n        type=\"button\"\n        className=\"hb-xb8-fab\"\n        aria-label={label}\n        aria-haspopup=\"menu\"\n        aria-expanded={isOpen}\n        aria-controls={`${id}-menu`}\n        onClick={() => setOpen(!isOpen)}\n        onKeyDown={(e) => {\n          if (!isOpen && (e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \")) {\n            focusFirst.current = true;\n            if (e.key === \"ArrowUp\") {\n              e.preventDefault();\n              e.stopPropagation();\n              setOpen(true);\n            }\n          } else if (isOpen && e.key === \"ArrowUp\") {\n            e.preventDefault();\n            e.stopPropagation();\n            refs.current[0]?.focus();\n          }\n        }}\n      >\n        <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n          <path d=\"M12 5v14M5 12h14\" />\n        </svg>\n      </button>\n    </div>\n  );\n}\n"
    }
  ]
}