{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dock",
  "title": "Dock",
  "description": "A macOS-style app dock with cursor-proximity magnification, running-app indicator dots, hover tooltips, separators and full keyboard navigation.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/dock/dock.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { motion, AnimatePresence, useMotionValue, useSpring, useTransform, type MotionValue } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type DockSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface DockItem {\n  id: string;\n  kind?: \"item\" | \"separator\";\n  label?: string;\n  icon?: React.ReactNode;\n  active?: boolean;\n  disabled?: boolean;\n  onClick?: () => void;\n}\n\nexport interface DockProps {\n  items: DockItem[];\n  onSelect?: (item: DockItem) => void;\n  size?: DockSize;\n  /** How much the icon under the cursor scales up, as a multiplier of the base size. */\n  magnification?: number;\n  /** How far (in px) the magnification effect reaches on either side of the cursor. */\n  distance?: number;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.5)\", bar: \"rgba(255,255,255,0.06)\", border: \"rgba(255,255,255,0.12)\", tile: \"rgba(255,255,255,0.08)\", tileActive: \"rgba(255,255,255,0.16)\", dot: \"#F5F4F1\", divider: \"rgba(255,255,255,0.14)\", tipBg: \"#161616\", tipBorder: \"rgba(255,255,255,0.12)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.5)\", bar: \"rgba(255,255,255,0.7)\", border: \"rgba(10,10,10,0.1)\", tile: \"rgba(10,10,10,0.05)\", tileActive: \"rgba(10,10,10,0.1)\", dot: \"#0A0A0A\", divider: \"rgba(10,10,10,0.12)\", tipBg: \"#FFFFFF\", tipBorder: \"rgba(10,10,10,0.1)\" },\n};\n\nconst SIZES: Record<DockSize, { base: number; radius: number; gap: number; padY: number; padX: number }> = {\n  sm: { base: 40, radius: 12, gap: 10, padY: 8, padX: 10 },\n  md: { base: 48, radius: 14, gap: 12, padY: 10, padX: 12 },\n  lg: { base: 56, radius: 16, gap: 14, padY: 12, padX: 14 },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nfunction DockTip({ label, theme, show, pos }: { label: string; theme: \"dark\" | \"light\"; show: boolean; pos: { x: number; y: number } }) {\n  const p = PALETTES[theme];\n  return typeof document === \"undefined\"\n    ? null\n    : createPortal(\n        <AnimatePresence>\n          {show && (\n            <motion.span\n              role=\"tooltip\"\n              initial={{ opacity: 0, y: 4, scale: 0.94 }}\n              animate={{ opacity: 1, y: 0, scale: 1 }}\n              exit={{ opacity: 0, y: 4, scale: 0.94 }}\n              transition={{ duration: 0.12 }}\n              className=\"pointer-events-none fixed z-[9999] font-medium whitespace-nowrap\"\n              style={{ left: pos.x, top: pos.y, transform: \"translate(-50%, -100%)\", padding: \"5px 9px\", borderRadius: 8, background: p.tipBg, border: `1px solid ${p.tipBorder}`, color: p.text, fontSize: 12.5, boxShadow: theme === \"dark\" ? \"0 12px 32px rgba(0,0,0,0.5)\" : \"0 12px 32px rgba(0,0,0,0.16)\" }}\n            >\n              {label}\n            </motion.span>\n          )}\n        </AnimatePresence>,\n        document.body,\n      );\n}\n\ninterface DockIconProps {\n  item: DockItem;\n  mouseX: MotionValue<number>;\n  baseSize: number;\n  magnification: number;\n  distance: number;\n  radius: number;\n  p: Palette;\n  theme: \"dark\" | \"light\";\n  tabIndex: number;\n  onFocus: () => void;\n  onActivate: () => void;\n  setRef: (el: HTMLButtonElement | null) => void;\n}\n\nfunction DockIcon({ item, mouseX, baseSize, magnification, distance, radius, p, theme, tabIndex, onFocus, onActivate, setRef }: DockIconProps) {\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const [hovered, setHovered] = React.useState(false);\n  // Magnify on keyboard focus only: a mouse click also focuses the button, and that focus would\n  // otherwise keep the icon enlarged after the pointer has left.\n  const [keyboardFocus, setKeyboardFocus] = React.useState(false);\n  const [tipPos, setTipPos] = React.useState({ x: 0, y: 0 });\n\n  const dist = useTransform(mouseX, (val) => {\n    const bounds = ref.current?.getBoundingClientRect();\n    if (!bounds) return distance * 2;\n    return val - (bounds.left + bounds.width / 2);\n  });\n  const sizeSync = useTransform(dist, [-distance, 0, distance], [baseSize, baseSize * magnification, baseSize]);\n  const springSize = useSpring(sizeSync, { mass: 0.15, stiffness: 300, damping: 18 });\n  const size = keyboardFocus ? baseSize * magnification : springSize;\n\n  const updateTip = () => {\n    const r = ref.current?.getBoundingClientRect();\n    if (r) setTipPos({ x: r.left + r.width / 2, y: r.top - 10 });\n  };\n\n  return (\n    <div className=\"relative flex flex-col items-center\" style={{ gap: 5 }}>\n      <motion.button\n        ref={(el) => {\n          ref.current = el;\n          setRef(el);\n        }}\n        type=\"button\"\n        aria-label={item.label}\n        aria-disabled={item.disabled || undefined}\n        aria-pressed={item.active || undefined}\n        disabled={item.disabled}\n        tabIndex={tabIndex}\n        onFocus={(e) => {\n          onFocus();\n          updateTip();\n          setHovered(true);\n          setKeyboardFocus(e.currentTarget.matches(\":focus-visible\"));\n        }}\n        onBlur={() => {\n          setHovered(false);\n          setKeyboardFocus(false);\n        }}\n        onMouseEnter={() => {\n          updateTip();\n          setHovered(true);\n        }}\n        onMouseLeave={() => setHovered(false)}\n        onClick={onActivate}\n        className=\"relative flex shrink-0 cursor-pointer items-center justify-center border-none outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-35\"\n        style={{ width: size, height: size, borderRadius: radius, background: item.active ? p.tileActive : p.tile, color: p.text, [\"--tw-ring-color\" as string]: p.text }}\n      >\n        <span className=\"flex items-center justify-center\" style={{ width: \"58%\", height: \"58%\" }}>\n          {item.icon}\n        </span>\n      </motion.button>\n      <span aria-hidden=\"true\" className=\"rounded-full\" style={{ width: 4, height: 4, background: item.active ? p.dot : \"transparent\" }} />\n      <DockTip label={item.label ?? \"\"} theme={theme} show={hovered && Boolean(item.label)} pos={tipPos} />\n    </div>\n  );\n}\n\nexport function Dock({ items, onSelect, size = \"md\", magnification = 1.7, distance = 140, theme = \"dark\", className }: DockProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const mouseX = useMotionValue(Infinity);\n  const [focusedId, setFocusedId] = React.useState<string | null>(null);\n  const enabledIds = items.filter((i) => i.kind !== \"separator\" && !i.disabled).map((i) => i.id);\n  const btnRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n\n  const move = (dir: 1 | -1) => {\n    if (enabledIds.length === 0) return;\n    const i = focusedId ? enabledIds.indexOf(focusedId) : -1;\n    const next = enabledIds[(i + dir + enabledIds.length) % enabledIds.length];\n    setFocusedId(next);\n    btnRefs.current[next]?.focus({ preventScroll: true });\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      move(1);\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      move(-1);\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      if (enabledIds.length) {\n        setFocusedId(enabledIds[0]);\n        btnRefs.current[enabledIds[0]]?.focus({ preventScroll: true });\n      }\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      if (enabledIds.length) {\n        const last = enabledIds[enabledIds.length - 1];\n        setFocusedId(last);\n        btnRefs.current[last]?.focus({ preventScroll: true });\n      }\n    }\n  };\n\n  return (\n    <div\n      role=\"toolbar\"\n      aria-label=\"Dock\"\n      onKeyDown={onKeyDown}\n      onMouseMove={(e) => mouseX.set(e.clientX)}\n      onMouseLeave={() => mouseX.set(Infinity)}\n      className={cn(\"inline-flex items-end\", className)}\n      style={{ gap: s.gap, padding: `${s.padY}px ${s.padX}px`, borderRadius: s.radius + 12, background: p.bar, border: `1px solid ${p.border}`, backdropFilter: \"blur(20px)\", WebkitBackdropFilter: \"blur(20px)\", fontFamily: \"Inter, sans-serif\" }}\n    >\n      {items.map((item) =>\n        item.kind === \"separator\" ? (\n          <div key={item.id} aria-hidden=\"true\" className=\"self-stretch\" style={{ width: 1, margin: `0 ${s.gap / 4}px`, background: p.divider }} />\n        ) : (\n          <DockIcon\n            key={item.id}\n            item={item}\n            mouseX={mouseX}\n            baseSize={s.base}\n            magnification={magnification}\n            distance={distance}\n            radius={s.radius}\n            p={p}\n            theme={theme}\n            tabIndex={item.id === (focusedId ?? enabledIds[0]) ? 0 : -1}\n            onFocus={() => setFocusedId(item.id)}\n            onActivate={() => {\n              if (item.disabled) return;\n              setFocusedId(item.id);\n              onSelect?.(item);\n              item.onClick?.();\n            }}\n            setRef={(el) => {\n              btnRefs.current[item.id] = el;\n            }}\n          />\n        ),\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}