{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"magnetic-nav-dock","type":"registry:component","title":"Magnetic Nav Dock","description":"A macOS-style dock where tiles swell on a smooth falloff around the pointer and push their neighbours aside. Crafted SVG app tiles, a label that glides between them, a sheen that follows the cursor, bounce on click and full keyboard support. No dependencies.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/magnetic-nav-dock.tsx","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type CSSProperties, type KeyboardEvent, type ReactNode } from \"react\";\n\nexport type MagneticNavDockProps = {\n  /**\n   * One entry per tile. Strings (an emoji, a word like \"home\", or a short label) and any ReactNode are accepted.\n   * Leave it out for the five built-in tiles: home, search, messages, files, settings.\n   */\n  icons?: ReactNode[];\n  /** Tooltip and accessible name per tile. Falls back to a name derived from the icon. */\n  labels?: string[];\n  /** Optional href per tile. A tile with an http(s), mailto, hash or relative href renders as a link. */\n  hrefs?: (string | undefined)[];\n  /** Resting tile size in px. */\n  baseSize?: number;\n  /** Tile size under the pointer in px. */\n  maxSize?: number;\n  /** Gap between tiles at rest, in px. */\n  gap?: number;\n  /** Half-width of the magnet field around the pointer, in px. */\n  reach?: number;\n  /** Index marked as current at first (uncontrolled). */\n  defaultActive?: number;\n  /** Controlled current index. */\n  activeIndex?: number;\n  /** Called when a tile is activated (click, tap, Enter, Space). */\n  onSelect?: (index: number, label: string) => void;\n  /** Accessible name of the nav landmark. */\n  ariaLabel?: string;\n  /** Goes on the outer element (position, margins). */\n  className?: string;\n};\n\ntype Glyph = \"home\" | \"search\" | \"messages\" | \"files\" | \"settings\";\n\nconst DEFAULT_ICONS: ReactNode[] = [\"home\", \"search\", \"messages\", \"files\", \"settings\"];\n\nconst GLYPH_NAMES: Record<string, Glyph> = {\n  home: \"home\",\n  \"\\u{1F3E0}\": \"home\",\n  search: \"search\",\n  \"\\u{1F50D}\": \"search\",\n  messages: \"messages\",\n  message: \"messages\",\n  chat: \"messages\",\n  \"\\u{1F4AC}\": \"messages\",\n  files: \"files\",\n  file: \"files\",\n  folder: \"files\",\n  \"\\u{1F4C1}\": \"files\",\n  settings: \"settings\",\n  \"⚙\": \"settings\",\n};\n\nconst GLYPH_LABEL: Record<Glyph, string> = {\n  home: \"Home\",\n  search: \"Search\",\n  messages: \"Messages\",\n  files: \"Files\",\n  settings: \"Settings\",\n};\n\nconst TILE_FILL: Record<Glyph | \"plain\", string> = {\n  home: \"linear-gradient(160deg, #6d97ff 0%, #3558ea 100%)\",\n  search: \"linear-gradient(160deg, #3ddbc8 0%, #0c8a86 100%)\",\n  messages: \"linear-gradient(160deg, #6be896 0%, #1b9d52 100%)\",\n  files: \"linear-gradient(160deg, #ffcb55 0%, #ec7d17 100%)\",\n  settings: \"linear-gradient(160deg, #9aa0ad 0%, #474b56 100%)\",\n  plain: \"linear-gradient(160deg, #4a4e5a 0%, #20222a 100%)\",\n};\n\nconst TILE_EDGE =\n  \"inset 0 1px 0 rgba(255,255,255,0.38), inset 0 0 0 1px rgba(255,255,255,0.14), inset 0 -10px 14px -8px rgba(0,0,0,0.38), 0 8px 16px -6px rgba(0,0,0,0.6)\";\n\nconst PAD_X = 16;\nconst PAD_T = 10;\nconst PAD_B = 16;\nconst GRAVITY = 2600;\nconst SPRING_K = 560;\nconst SPRING_C = 42;\n\nconst CSS = [\n  \".mnd-tile{transition:transform 140ms cubic-bezier(.2,.8,.2,1)}\",\n  \".mnd-btn:active .mnd-tile{transform:scale(.93)}\",\n  \".mnd-btn:focus-visible{outline:2px solid #fff!important;outline-offset:3px!important;border-radius:27%!important}\",\n  \"@media (prefers-reduced-motion:reduce){.mnd-tile{transition:none}.mnd-btn:active .mnd-tile{transform:none}}\",\n].join(\"\");\n\nfunction glyphOf(icon: ReactNode): Glyph | null {\n  if (typeof icon !== \"string\") return null;\n  const key = icon.replace(/️/g, \"\").trim().toLowerCase();\n  return GLYPH_NAMES[key] ?? null;\n}\n\nfunction labelOf(icon: ReactNode, i: number, labels?: string[]): string {\n  const given = labels?.[i];\n  if (given) return given;\n  const g = glyphOf(icon);\n  if (g) return GLYPH_LABEL[g];\n  if (typeof icon === \"string\" && icon.trim()) return icon.trim();\n  return \"Item \" + (i + 1);\n}\n\nfunction safeHref(h: string | undefined): string | undefined {\n  if (!h || /\\\\/.test(h)) return undefined;\n  if (/^(https?:|mailto:|tel:|#|\\/(?!\\/)|\\.{0,2}\\/)/i.test(h)) return h;\n  return undefined;\n}\n\nfunction GlyphArt({ glyph }: { glyph: Glyph }) {\n  const common = {\n    fill: \"none\",\n    stroke: \"#fff\",\n    strokeWidth: 2.7,\n    strokeLinecap: \"round\" as const,\n    strokeLinejoin: \"round\" as const,\n  };\n  return (\n    <svg viewBox=\"0 0 48 48\" width=\"100%\" height=\"100%\" aria-hidden focusable=\"false\" style={{ display: \"block\", filter: \"drop-shadow(0 1.5px 1px rgba(0,0,0,0.28))\" }}>\n      {glyph === \"home\" && (\n        <g {...common}>\n          <path d=\"M11.5 23.5 24 12.5l12.5 11\" />\n          <path d=\"M15.5 21.5V35h17V21.5\" />\n          <path d=\"M21 35v-8h6v8\" />\n        </g>\n      )}\n      {glyph === \"search\" && (\n        <g {...common}>\n          <circle cx=\"21.5\" cy=\"21.5\" r=\"9\" />\n          <path d=\"m28.5 28.5 8 8\" />\n        </g>\n      )}\n      {glyph === \"messages\" && (\n        <g>\n          <path\n            d=\"M14 16.5A4.5 4.5 0 0 1 18.5 12h11a4.5 4.5 0 0 1 4.5 4.5v8a4.5 4.5 0 0 1-4.5 4.5H25l-6.5 5v-5A4.5 4.5 0 0 1 14 24.5Z\"\n            {...common}\n          />\n          <circle cx=\"20\" cy=\"20.5\" r=\"1.7\" fill=\"#fff\" />\n          <circle cx=\"24\" cy=\"20.5\" r=\"1.7\" fill=\"#fff\" />\n          <circle cx=\"28\" cy=\"20.5\" r=\"1.7\" fill=\"#fff\" />\n        </g>\n      )}\n      {glyph === \"files\" && (\n        <path\n          d=\"M11.5 18.5a3 3 0 0 1 3-3h6.2l3 3.6h10.8a3 3 0 0 1 3 3V32a3 3 0 0 1-3 3h-20a3 3 0 0 1-3-3Z\"\n          {...common}\n          fill=\"rgba(255,255,255,0.2)\"\n        />\n      )}\n      {glyph === \"settings\" && (\n        <g>\n          <g {...common} strokeWidth={2.4} opacity={0.6}>\n            <path d=\"M12 17h24M12 24h24M12 31h24\" />\n          </g>\n          <circle cx=\"19\" cy=\"17\" r=\"3.4\" fill=\"#fff\" />\n          <circle cx=\"30\" cy=\"24\" r=\"3.4\" fill=\"#fff\" />\n          <circle cx=\"22\" cy=\"31\" r=\"3.4\" fill=\"#fff\" />\n        </g>\n      )}\n    </svg>\n  );\n}\n\nfunction Tile({ icon }: { icon: ReactNode }) {\n  const g = glyphOf(icon);\n  return (\n    <>\n      <span aria-hidden className=\"absolute inset-0 block overflow-hidden\" style={{ borderRadius: \"inherit\", background: TILE_FILL[g ?? \"plain\"], boxShadow: TILE_EDGE }}>\n        <span\n          className=\"absolute inset-x-0 top-0 block\"\n          style={{ height: \"52%\", background: \"linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0))\" }}\n        />\n      </span>\n      <span aria-hidden className=\"relative flex h-full w-full items-center justify-center\" style={{ padding: g ? \"8%\" : 0 }}>\n        {g ? (\n          <GlyphArt glyph={g} />\n        ) : (\n          <span style={{ color: \"#fff\", fontSize: \"0.46em\", fontWeight: 600, lineHeight: 1, letterSpacing: \"-0.01em\" }}>\n            {typeof icon === \"string\" ? Array.from(icon.trim()).slice(0, 2).join(\"\") : icon}\n          </span>\n        )}\n      </span>\n    </>\n  );\n}\n\ntype Input = { px: number | null; fx: number | null; fi: number; flash: number; bounce: number[] };\n\nexport function MagneticNavDock({\n  icons = DEFAULT_ICONS,\n  labels,\n  hrefs,\n  baseSize = 44,\n  maxSize = 72,\n  gap = 12,\n  reach = 120,\n  defaultActive = 0,\n  activeIndex,\n  onSelect,\n  ariaLabel = \"Dock\",\n  className,\n}: MagneticNavDockProps) {\n  const n = icons.length;\n  const base = Math.max(16, baseSize);\n  const max = Math.max(base, maxSize);\n  const restW = PAD_X * 2 + n * base + Math.max(0, n - 1) * gap;\n  const barH = PAD_T + base + PAD_B;\n\n  const [innerActive, setInnerActive] = useState(defaultActive);\n  const [roving, setRoving] = useState(Math.min(Math.max(0, defaultActive), Math.max(0, n - 1)));\n  const active = activeIndex ?? innerActive;\n\n  const rootRef = useRef<HTMLDivElement>(null);\n  const barRef = useRef<HTMLDivElement>(null);\n  const tipRef = useRef<HTMLDivElement>(null);\n  const liRefs = useRef<(HTMLLIElement | null)[]>([]);\n  const liftRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const tileRefs = useRef<(HTMLSpanElement | null)[]>([]);\n  const ctlRefs = useRef<(HTMLElement | null)[]>([]);\n  const input = useRef<Input>({ px: null, fx: null, fi: -1, flash: -1, bounce: [] });\n  const cfg = useRef({ base, max, gap, reach: Math.max(24, reach), reduced: false, restW, labels: [] as string[] });\n  const wake = useRef<() => void>(() => {});\n  const lastType = useRef(\"mouse\");\n\n  const labelList = icons.map((ic, i) => labelOf(ic, i, labels));\n  const labelKey = labelList.join(\"\\u0001\");\n\n  useEffect(() => {\n    cfg.current = { ...cfg.current, base, max, gap, reach: Math.max(24, reach), restW, labels: labelKey ? labelKey.split(\"\\u0001\") : [] };\n    wake.current();\n  }, [base, max, gap, reach, restW, labelKey]);\n\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const set = () => {\n      cfg.current.reduced = mq.matches;\n      wake.current();\n    };\n    set();\n    mq.addEventListener(\"change\", set);\n    return () => mq.removeEventListener(\"change\", set);\n  }, []);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const bar = barRef.current;\n    const tip = tipRef.current;\n    if (!root || !bar || !tip) return;\n    const s = new Float64Array(n).fill(cfg.current.base);\n    const sv = new Float64Array(n);\n    const hot = new Float64Array(n);\n    const ly = new Float64Array(n);\n    const lv = new Float64Array(n);\n    const xs = new Float64Array(n);\n    let raf = 0;\n    let last = 0;\n    let tipX = 0;\n    let tipB = 0;\n    let tipO = 0;\n    let tipIdx = -1;\n    let flashIdx = -1;\n    let flashUntil = 0;\n    let gx = 0;\n    let go = 0;\n\n    const frame = (t: number) => {\n      raf = 0;\n      const dt = last ? Math.min((t - last) / 1000, 1 / 30) : 1 / 60;\n      last = t;\n      const c = cfg.current;\n      const inp = input.current;\n      const anchor = inp.px ?? inp.fx;\n      let moving = false;\n\n      if (inp.flash >= 0) {\n        flashIdx = inp.flash;\n        flashUntil = t + 1200;\n        inp.flash = -1;\n      }\n      while (inp.bounce.length) {\n        const bi = inp.bounce.pop();\n        if (bi === undefined || bi >= n || c.reduced) continue;\n        lv[bi] = Math.sqrt(2 * GRAVITY * 0.5 * (s[bi] ?? c.base));\n        ly[bi] = 0.01;\n      }\n\n      const rc = (i: number) => PAD_X + i * (c.base + c.gap) + c.base / 2;\n      let near = -1;\n      let nearD = Infinity;\n      let sum = 0;\n      for (let i = 0; i < n; i++) {\n        const d = anchor === null ? Infinity : Math.abs(anchor - rc(i));\n        if (d < nearD) {\n          nearD = d;\n          near = i;\n        }\n        const u = Math.max(0, 1 - d / c.reach);\n        const hf = anchor === null ? 0 : u * u * (3 - 2 * u);\n        const f = c.reduced ? 0 : hf;\n        const target = c.base + (c.max - c.base) * f;\n        let p = s[i] ?? c.base;\n        let v = sv[i] ?? 0;\n        const h = dt / 2;\n        for (let k = 0; k < 2; k++) {\n          v += (SPRING_K * (target - p) - SPRING_C * v) * h;\n          p += v * h;\n        }\n        if (Math.abs(target - p) < 0.02 && Math.abs(v) < 0.4) {\n          p = target;\n          v = 0;\n        } else moving = true;\n        s[i] = p;\n        sv[i] = v;\n        sum += p;\n\n        const hh = hot[i] ?? 0;\n        const nh = hh + (hf - hh) * (1 - Math.exp(-dt * 16));\n        hot[i] = Math.abs(hf - nh) < 0.003 ? hf : nh;\n        if (hot[i] !== hf) moving = true;\n\n        let y = ly[i] ?? 0;\n        let yv = lv[i] ?? 0;\n        if (y > 0 || yv > 0) {\n          yv -= GRAVITY * dt;\n          y += yv * dt;\n          if (y <= 0) {\n            y = 0;\n            yv = yv < -70 ? -yv * 0.42 : 0;\n          }\n          moving = true;\n        }\n        ly[i] = y;\n        lv[i] = yv;\n      }\n\n      const W = PAD_X * 2 + sum + Math.max(0, n - 1) * c.gap;\n      const barLeft = (c.restW - W) / 2;\n      bar.style.width = W + \"px\";\n      bar.style.left = barLeft + \"px\";\n      let x = PAD_X;\n      for (let i = 0; i < n; i++) {\n        const size = s[i] ?? c.base;\n        xs[i] = x;\n        const li = liRefs.current[i];\n        if (li) {\n          li.style.left = x + \"px\";\n          li.style.width = size + \"px\";\n          li.style.height = size + \"px\";\n          li.style.fontSize = size + \"px\";\n        }\n        const lift = liftRefs.current[i];\n        if (lift) lift.style.transform = \"translate3d(0,\" + -(ly[i] ?? 0) + \"px,0)\";\n        const tile = tileRefs.current[i];\n        if (tile) tile.style.filter = \"brightness(\" + (1 + 0.1 * (hot[i] ?? 0)).toFixed(3) + \")\";\n        x += size + c.gap;\n      }\n\n      // tooltip\n      let idx = -1;\n      if (inp.px !== null) idx = near;\n      else if (inp.fx !== null) idx = inp.fi;\n      else if (t < flashUntil) idx = flashIdx;\n      if (idx >= n) idx = -1;\n      const wasHidden = tipO < 0.03;\n      if (idx >= 0) {\n        if (idx !== tipIdx) {\n          tip.textContent = c.labels[idx] ?? \"\";\n          tipIdx = idx;\n        }\n        const tx = (xs[idx] ?? 0) + (s[idx] ?? c.base) / 2;\n        const tb = PAD_B + (s[idx] ?? c.base) + (ly[idx] ?? 0) + 10;\n        if (wasHidden || c.reduced) {\n          tipX = tx;\n          tipB = tb;\n        } else {\n          const k = 1 - Math.exp(-dt * 26);\n          tipX += (tx - tipX) * k;\n          tipB += (tb - tipB) * k;\n          if (Math.abs(tx - tipX) > 0.3 || Math.abs(tb - tipB) > 0.3) moving = true;\n        }\n      }\n      const to = idx >= 0 ? 1 : 0;\n      tipO += (to - tipO) * (1 - Math.exp(-dt * 18));\n      if (Math.abs(to - tipO) < 0.01) tipO = to;\n      else moving = true;\n      if (t < flashUntil) moving = true;\n      tip.style.opacity = String(tipO);\n      tip.style.left = tipX + \"px\";\n      tip.style.bottom = tipB + \"px\";\n      tip.style.transform = \"translate3d(-50%,\" + (1 - tipO) * 6 + \"px,0)\";\n\n      // surface sheen under the pointer\n      if (anchor !== null) {\n        const gt = anchor - barLeft;\n        gx = go < 0.03 ? gt : gx + (gt - gx) * (1 - Math.exp(-dt * 30));\n        if (Math.abs(gt - gx) > 0.3) moving = true;\n      }\n      const gto = anchor === null ? 0 : 1;\n      go += (gto - go) * (1 - Math.exp(-dt * 10));\n      if (Math.abs(gto - go) < 0.01) go = gto;\n      else moving = true;\n      bar.style.setProperty(\"--mnd-gx\", gx.toFixed(1) + \"px\");\n      bar.style.setProperty(\"--mnd-go\", go.toFixed(3));\n\n      if (moving) raf = requestAnimationFrame(frame);\n      else last = 0;\n    };\n\n    const start = () => {\n      if (!raf) raf = requestAnimationFrame(frame);\n    };\n    wake.current = start;\n\n    const onMove = (e: PointerEvent) => {\n      const inp = input.current;\n      if (e.pointerType === \"touch\") {\n        if (inp.px !== null) {\n          inp.px = null;\n          start();\n        }\n        return;\n      }\n      const r = root.getBoundingClientRect();\n      if (!r.width) return;\n      const k = root.offsetWidth / r.width;\n      const lx = (e.clientX - r.left) * k;\n      const lyy = (e.clientY - r.top) * k;\n      const c = cfg.current;\n      const inside = lx > -24 && lx < c.restW + 24 && lyy > -(c.max - c.base) - 40 && lyy < c.base + PAD_T + PAD_B + 16;\n      const next = inside ? lx : null;\n      if (next !== inp.px) {\n        inp.px = next;\n        start();\n      }\n    };\n    const onLeave = () => {\n      if (input.current.px !== null) {\n        input.current.px = null;\n        start();\n      }\n    };\n    document.addEventListener(\"pointermove\", onMove, { passive: true });\n    document.documentElement.addEventListener(\"pointerleave\", onLeave);\n    window.addEventListener(\"blur\", onLeave);\n    start();\n    return () => {\n      cancelAnimationFrame(raf);\n      wake.current = () => {};\n      document.removeEventListener(\"pointermove\", onMove);\n      document.documentElement.removeEventListener(\"pointerleave\", onLeave);\n      window.removeEventListener(\"blur\", onLeave);\n    };\n  }, [n]);\n\n  const focusAt = (i: number) => {\n    const j = (i + n) % n;\n    ctlRefs.current[j]?.focus();\n  };\n\n  const onKeyDown = (e: KeyboardEvent<HTMLElement>) => {\n    const cur = ctlRefs.current.findIndex((el) => el === document.activeElement);\n    if (cur < 0) return;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") focusAt(cur + 1);\n    else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") focusAt(cur - 1);\n    else if (e.key === \"Home\") focusAt(0);\n    else if (e.key === \"End\") focusAt(n - 1);\n    else return;\n    e.preventDefault();\n  };\n\n  const activate = (i: number, detail: number) => {\n    if (activeIndex === undefined) setInnerActive(i);\n    onSelect?.(i, labelList[i] ?? \"\");\n    input.current.bounce.push(i);\n    if (lastType.current === \"touch\" || (detail === 0 && input.current.fx === null)) input.current.flash = i;\n    wake.current();\n  };\n\n  return (\n    <div ref={rootRef} className={\"relative shrink-0 \" + (className ?? \"\")} style={{ width: restW, height: barH }}>\n      <style>{CSS}</style>\n      <nav aria-label={ariaLabel} className=\"contents\">\n        <div\n          ref={barRef}\n          onKeyDown={onKeyDown}\n          className=\"absolute bottom-0\"\n          style={\n            {\n              left: 0,\n              width: restW,\n              height: barH,\n              borderRadius: Math.round(base * 0.56),\n              background: \"linear-gradient(180deg, rgba(34,36,43,0.86), rgba(14,15,19,0.9))\",\n              boxShadow:\n                \"inset 0 0 0 1px rgba(255,255,255,0.1), inset 0 1px 0 rgba(255,255,255,0.18), 0 22px 44px -14px rgba(0,0,0,0.65), 0 6px 14px -4px rgba(0,0,0,0.4)\",\n              backdropFilter: \"blur(22px) saturate(1.5)\",\n              WebkitBackdropFilter: \"blur(22px) saturate(1.5)\",\n              \"--mnd-gx\": \"0px\",\n              \"--mnd-go\": \"0\",\n            } as CSSProperties\n          }\n        >\n          <span\n            aria-hidden\n            className=\"pointer-events-none absolute inset-0 block\"\n            style={{\n              borderRadius: \"inherit\",\n              background: \"radial-gradient(160px 70px at var(--mnd-gx) 0%, rgba(255,255,255,calc(var(--mnd-go) * 0.2)), transparent 70%)\",\n            }}\n          />\n          <ul role=\"list\" className=\"m-0 list-none p-0\">\n            {icons.map((icon, i) => {\n              const label = labelList[i] ?? \"\";\n              const isActive = i === active;\n              const href = safeHref(hrefs?.[i]);\n              const left = PAD_X + i * (base + gap);\n              const ctlProps = {\n                ref: (el: HTMLElement | null) => {\n                  ctlRefs.current[i] = el;\n                },\n                \"aria-label\": label,\n                \"aria-current\": isActive ? (\"page\" as const) : undefined,\n                tabIndex: i === roving ? 0 : -1,\n                className: \"mnd-btn relative block h-full w-full cursor-pointer border-0 bg-transparent p-0 no-underline\",\n                style: { borderRadius: \"27%\", outline: \"none\", WebkitTapHighlightColor: \"transparent\", touchAction: \"manipulation\" } as CSSProperties,\n                onPointerDown: (e: { pointerType: string }) => {\n                  lastType.current = e.pointerType;\n                },\n                onClick: (e: { detail: number }) => activate(i, e.detail),\n                onFocus: (e: { currentTarget: HTMLElement }) => {\n                  setRoving(i);\n                  const inp = input.current;\n                  let vis = false;\n                  try {\n                    vis = e.currentTarget.matches(\":focus-visible\");\n                  } catch {\n                    vis = false;\n                  }\n                  inp.fi = i;\n                  inp.fx = vis ? PAD_X + i * (cfg.current.base + cfg.current.gap) + cfg.current.base / 2 : null;\n                  wake.current();\n                },\n                onBlur: () => {\n                  input.current.fx = null;\n                  wake.current();\n                },\n              };\n              const face = (\n                <span\n                  ref={(el) => {\n                    tileRefs.current[i] = el;\n                  }}\n                  className=\"mnd-tile absolute inset-0 block\"\n                  style={{ borderRadius: \"27%\" }}\n                >\n                  <Tile icon={icon} />\n                </span>\n              );\n              return (\n                <li\n                  key={i}\n                  ref={(el) => {\n                    liRefs.current[i] = el;\n                  }}\n                  className=\"absolute\"\n                  style={{ left, bottom: PAD_B, width: base, height: base, fontSize: base }}\n                >\n                  <div\n                    ref={(el) => {\n                      liftRefs.current[i] = el;\n                    }}\n                    className=\"h-full w-full\"\n                  >\n                    {href ? (\n                      <a href={href} {...ctlProps}>\n                        {face}\n                      </a>\n                    ) : (\n                      <button type=\"button\" {...ctlProps}>\n                        {face}\n                      </button>\n                    )}\n                  </div>\n                  <span\n                    aria-hidden\n                    className=\"pointer-events-none absolute left-1/2 block rounded-full\"\n                    style={{\n                      top: \"100%\",\n                      marginTop: 7,\n                      width: 4,\n                      height: 4,\n                      marginLeft: -2,\n                      background: \"#fff\",\n                      boxShadow: \"0 0 6px rgba(255,255,255,0.7)\",\n                      opacity: isActive ? 0.9 : 0,\n                      transform: isActive ? \"scale(1)\" : \"scale(0.3)\",\n                      transition: \"opacity 200ms ease, transform 260ms cubic-bezier(.2,.9,.3,1.4)\",\n                    }}\n                  />\n                </li>\n              );\n            })}\n          </ul>\n          <div\n            ref={tipRef}\n            aria-hidden\n            className=\"pointer-events-none absolute whitespace-nowrap\"\n            style={{\n              left: 0,\n              bottom: PAD_B + base + 10,\n              opacity: 0,\n              padding: \"6px 11px\",\n              borderRadius: 10,\n              fontSize: 12,\n              lineHeight: 1,\n              fontWeight: 500,\n              letterSpacing: \"0.01em\",\n              color: \"#f4f5f7\",\n              background: \"rgba(12,13,16,0.92)\",\n              boxShadow: \"inset 0 0 0 1px rgba(255,255,255,0.12), 0 8px 20px -6px rgba(0,0,0,0.6)\",\n              transform: \"translate3d(-50%,6px,0)\",\n            }}\n          />\n        </div>\n      </nav>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/magnetic-nav-dock.tsx"}],"meta":{"tier":"free","tags":["dock","nav","magnetic","cursor","spring","macos","icons","navigation"],"href":"https://viberdy.dev/library/magnetic-nav-dock","aiPrompt":"Build a React + Tailwind component named MagneticNavDock: a macOS-style dock whose tiles swell around the pointer. One \"use client\" file, React only (no animation library).\n\nProps (all optional): icons (ReactNode[], default the five tiles home/search/messages/files/settings; strings such as an emoji, a word like \"home\" or a short label are accepted, and any node), labels (string[]), hrefs (string[], safe http(s)/mailto/tel/hash/relative only, renders <a> instead of <button>), baseSize 44, maxSize 72, gap 12, reach 120, defaultActive 0, activeIndex (controlled), onSelect(index, label), ariaLabel \"Dock\", className.\n\nLayout: the root is position:relative, width = 32 + n*baseSize + (n-1)*gap, height = baseSize + 26 (padding 16 left/right, 10 top, 16 bottom). Inside, an absolutely positioned glass bar (dark vertical gradient rgba(34,36,43,.86) to rgba(14,15,19,.9), blur 22px saturate 1.5, 1px inset white/10 edge, top highlight, deep soft shadow, radius about 0.56*baseSize). Tiles are absolutely positioned list items bottom-aligned at 16px; magnified tiles rise above the bar.\n\nMotion: ONE requestAnimationFrame loop in a mount effect that sleeps when everything is at rest and writes straight to the DOM (no React renders while moving). Per tile: target size = base + (max-base)*smoothstep(1 - |pointerX - restCenter|/reach), where restCenter is measured against the RESTING layout (never the magnified one, so there is no feedback). Each size follows a damped spring (k=560, c=42, two substeps per frame, dt clamped to 1/30). The loop lays tiles out cumulatively with the gap and widens the bar symmetrically around the root centre. A \"hot\" value (smoothed, rate 16/s) brightens the nearest tiles up to +10%.\nClick: ballistic bounce, gravity 2600 px/s^2, launch speed sqrt(2*g*0.5*size), floor restitution 0.42, stops below 70px/s. A single tooltip pill (12px, 500 weight, near-black glass) sits 10px above the focused tile and glides to the next tile with exp smoothing (rate 26/s), fading at rate 18/s. A radial sheen on the bar's top edge (160x70) follows the pointer at up to 20% white.\nPointer: one document pointermove listener maps clientX/Y into root layout pixels using (client - rect.left) * (offsetWidth / rect.width); inside the zone (24px sideways, maxSize-baseSize+40px above, 16px below) it sets the anchor, else clears it; touch pointers never set it. Do not block clicks on the page around the dock.\nTiles: 27% radius squircles with a gradient per glyph (home blue, search teal, messages green, files amber, settings graphite), inset top highlight and edge, a gloss over the upper 52%, white 2.7-stroke SVG glyphs on a 48 grid (house, magnifier, chat bubble with three dots, folder, three sliders) with a faint drop shadow. Unknown strings/nodes render in a graphite tile. A pressed tile scales to 0.93 in 140ms. The active tile shows a 4px white dot 7px below it.\n\nA11y: <nav aria-label>, a list of real <button type=\"button\"> (or <a>) per tile with aria-label and aria-current for the active one, roving tabindex (Tab enters once; Arrow keys, Home, End move focus), keyboard focus (:focus-visible) acts as the anchor and shows the tooltip, Enter/Space activate with a bounce, a 2px white focus ring with 3px offset (!important so site CSS cannot remove it). Touch: tap presses, bounces and flashes the label for 1.2s; no hover swell. prefers-reduced-motion: no swell, no bounce, tooltip snaps to place and fades, tiles only brighten.","license":"https://viberdy.dev/license"}}