{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "navbar",
  "type": "registry:ui",
  "title": "Navbar",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Kinetic responsive navigation bar with scroll-direction sensing, shared-layout spring indicators, multi-level dropdowns, and an animated mobile drawer.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/navbar.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useEffect, useRef, useId } from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"framer-motion\";\nimport { Menu, X, ChevronDown, Sparkles } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface NavbarDropdownItem {\n  label: string;\n  href: string;\n  description?: string;\n  icon?: React.ComponentType<{ className?: string }>;\n  badge?: string;\n}\n\nexport interface NavbarItem {\n  label: string;\n  href: string;\n  icon?: React.ComponentType<{ className?: string }>;\n  badge?: string;\n  children?: NavbarDropdownItem[];\n}\n\nexport interface NavbarAction {\n  label: string;\n  href?: string;\n  onClick?: () => void;\n  variant?: \"primary\" | \"secondary\" | \"ghost\";\n  icon?: React.ComponentType<{ className?: string }>;\n}\n\nexport interface NavbarProps extends React.HTMLAttributes<HTMLElement> {\n  /** Brand identity logo or element */\n  brand?: React.ReactNode;\n  /** Navigation links and sub-menus */\n  items?: NavbarItem[];\n  /** Right-aligned action buttons or call-to-actions */\n  actions?: NavbarAction[];\n  /** Visual style variant: \"floating\" island, \"fixed\" top bar, or \"glass\" header */\n  variant?: \"floating\" | \"fixed\" | \"glass\";\n  /** Positioning mode: \"fixed\" at top of viewport, \"sticky\", or \"static\" for embedded/preview containers */\n  position?: \"fixed\" | \"sticky\" | \"static\";\n  /** Whether to intelligently hide navbar on scroll down and reveal on scroll up */\n  hideOnScroll?: boolean;\n  /** Currently active item href */\n  activeHref?: string;\n  /** Callback fired when a navigation item is selected */\n  onNavigate?: (href: string) => void;\n  /** Optional custom Tailwind classes */\n  className?: string;\n}\n\nconst DEFAULT_ITEMS: NavbarItem[] = [\n  { label: \"Features\", href: \"#features\" },\n  {\n    label: \"Products\",\n    href: \"#products\",\n    badge: \"New\",\n    children: [\n      {\n        label: \"Kinetic Primitives\",\n        href: \"#primitives\",\n        description: \"Zero-dependency spring-animated interactive components.\",\n        icon: Sparkles,\n      },\n      {\n        label: \"Application Blocks\",\n        href: \"#blocks\",\n        description: \"Composite dashboard, hero, and feature sections.\",\n      },\n      {\n        label: \"Design Tokens\",\n        href: \"#tokens\",\n        description: \"Curated palettes, fluid typography, and kinetic easings.\",\n      },\n    ],\n  },\n  { label: \"Showcase\", href: \"#showcase\" },\n  { label: \"Docs\", href: \"#docs\" },\n];\n\nconst DEFAULT_ACTIONS: NavbarAction[] = [\n  { label: \"Sign In\", href: \"#signin\", variant: \"ghost\" },\n  { label: \"Get Started\", href: \"#get-started\", variant: \"primary\" },\n];\n\nexport function Navbar({\n  brand,\n  items = DEFAULT_ITEMS,\n  actions = DEFAULT_ACTIONS,\n  variant = \"floating\",\n  position = \"fixed\",\n  hideOnScroll = true,\n  activeHref = \"#features\",\n  onNavigate,\n  className,\n  ...props\n}: NavbarProps) {\n  const [isVisible, setIsVisible] = useState(true);\n  const [lastScrollY, setLastScrollY] = useState(0);\n  const [hoveredIdx, setHoveredIdx] = useState<number | null>(null);\n  const [activeDropdown, setActiveDropdown] = useState<number | null>(null);\n  const [mobileMenuOpen, setMobileMenuOpen] = useState(false);\n  const [currentActive, setCurrentActive] = useState(activeHref);\n  const dropdownTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n  const shouldReduceMotion = useReducedMotion();\n  const instanceId = useId();\n\n  // Scroll detection for auto hide/reveal\n  useEffect(() => {\n    if (!hideOnScroll) return;\n\n    const handleScroll = () => {\n      const currentScrollY = window.scrollY;\n      if (currentScrollY < 40) {\n        setIsVisible(true);\n      } else if (currentScrollY > lastScrollY + 8 && currentScrollY > 100) {\n        setIsVisible(false);\n        setActiveDropdown(null);\n      } else if (currentScrollY < lastScrollY - 8) {\n        setIsVisible(true);\n      }\n      setLastScrollY(currentScrollY);\n    };\n\n    window.addEventListener(\"scroll\", handleScroll, { passive: true });\n    return () => window.removeEventListener(\"scroll\", handleScroll);\n  }, [hideOnScroll, lastScrollY]);\n\n  // Close dropdown on escape key\n  useEffect(() => {\n    const handleKeyDown = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setActiveDropdown(null);\n        setMobileMenuOpen(false);\n      }\n    };\n    window.addEventListener(\"keydown\", handleKeyDown);\n    return () => window.removeEventListener(\"keydown\", handleKeyDown);\n  }, []);\n\n  const handleDropdownEnter = (idx: number) => {\n    if (dropdownTimeoutRef.current) clearTimeout(dropdownTimeoutRef.current);\n    setActiveDropdown(idx);\n  };\n\n  const handleDropdownLeave = () => {\n    dropdownTimeoutRef.current = setTimeout(() => {\n      setActiveDropdown(null);\n    }, 150);\n  };\n\n  const handleItemClick = (href: string) => {\n    setCurrentActive(href);\n    setActiveDropdown(null);\n    setMobileMenuOpen(false);\n    onNavigate?.(href);\n  };\n\n  const variantStyles = {\n    floating:\n      \"mx-auto mt-4 w-[92%] max-w-6xl rounded-2xl border border-neutral-200/80 bg-white/80 shadow-lg shadow-neutral-900/5 backdrop-blur-xl dark:border-neutral-800/80 dark:bg-neutral-950/80 dark:shadow-black/20\",\n    fixed:\n      \"w-full border-b border-neutral-200 bg-white/95 shadow-sm dark:border-neutral-800 dark:bg-neutral-950/95\",\n    glass:\n      \"w-full border-b border-white/20 bg-white/40 shadow-sm backdrop-blur-md dark:border-white/10 dark:bg-neutral-950/40\",\n  };\n\n  return (\n    <header\n      className={cn(\n        position === \"static\"\n          ? \"relative w-full z-20\"\n          : position === \"sticky\"\n          ? \"sticky top-0 left-0 right-0 z-50 transition-transform duration-300\"\n          : \"fixed top-0 left-0 right-0 z-50 transition-transform duration-300\",\n        position !== \"static\" && (isVisible ? \"translate-y-0\" : \"-translate-y-full\"),\n        variant === \"floating\" && position !== \"static\" ? \"pointer-events-none\" : \"\"\n      )}\n      {...props}\n    >\n      <nav\n        aria-label=\"Main Navigation\"\n        className={cn(\n          \"pointer-events-auto relative px-4 py-2.5 sm:px-6\",\n          variantStyles[variant],\n          className\n        )}\n      >\n        <div className=\"flex items-center justify-between gap-4\">\n          {/* Brand Logo / Slot */}\n          <div className=\"flex items-center gap-2\">\n            {brand || (\n              <a\n                href=\"#\"\n                onClick={(e) => {\n                  e.preventDefault();\n                  handleItemClick(\"#\");\n                }}\n                className=\"group flex items-center gap-2.5 text-base font-bold tracking-tight text-neutral-900 transition-colors dark:text-white\"\n              >\n                <div className=\"flex h-8 w-8 items-center justify-center rounded-lg bg-neutral-900 text-white shadow-sm transition-transform group-hover:scale-105 dark:bg-white dark:text-neutral-950\">\n                  <span className=\"font-mono text-sm font-black\">B</span>\n                </div>\n                <span className=\"bg-gradient-to-r from-neutral-900 to-neutral-700 bg-clip-text text-transparent dark:from-white dark:to-neutral-300\">\n                  BoseUI\n                </span>\n              </a>\n            )}\n          </div>\n\n          {/* Desktop Navigation Links */}\n          <div\n            className=\"hidden md:flex items-center gap-1\"\n            onMouseLeave={() => setHoveredIdx(null)}\n          >\n            {items.map((item, idx) => {\n              const isActive = currentActive === item.href;\n              const isHovered = hoveredIdx === idx;\n              const hasDropdown = Boolean(item.children && item.children.length > 0);\n              const isDropdownOpen = activeDropdown === idx;\n\n              return (\n                <div\n                  key={item.label}\n                  className=\"relative\"\n                  onMouseEnter={() => {\n                    setHoveredIdx(idx);\n                    if (hasDropdown) handleDropdownEnter(idx);\n                    else setActiveDropdown(null);\n                  }}\n                  onMouseLeave={() => {\n                    if (hasDropdown) handleDropdownLeave();\n                  }}\n                >\n                  <a\n                    href={item.href}\n                    onClick={(e) => {\n                      if (!hasDropdown) {\n                        e.preventDefault();\n                        handleItemClick(item.href);\n                      }\n                    }}\n                    aria-current={isActive ? \"page\" : undefined}\n                    aria-expanded={hasDropdown ? isDropdownOpen : undefined}\n                    aria-haspopup={hasDropdown ? \"true\" : undefined}\n                    className={cn(\n                      \"relative flex items-center gap-1.5 rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 dark:focus-visible:ring-neutral-600\",\n                      isActive\n                        ? \"text-neutral-950 font-semibold dark:text-white\"\n                        : \"text-neutral-600 hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\"\n                    )}\n                  >\n                    {/* Shared Layout Hover Pill */}\n                    {isHovered && !shouldReduceMotion && (\n                      <motion.div\n                        layoutId={`navbar-hover-${instanceId}`}\n                        className=\"absolute inset-0 rounded-lg bg-neutral-100/90 dark:bg-neutral-800/80 -z-10\"\n                        transition={{\n                          type: \"spring\",\n                          stiffness: 400,\n                          damping: 30,\n                        }}\n                      />\n                    )}\n\n                    {/* Active Link Spring Indicator */}\n                    {isActive && (\n                      <motion.div\n                        layoutId={`navbar-active-${instanceId}`}\n                        className=\"absolute -bottom-1 left-3 right-3 h-0.5 rounded-full bg-neutral-950 dark:bg-white\"\n                        transition={{\n                          type: \"spring\",\n                          stiffness: 380,\n                          damping: 28,\n                        }}\n                      />\n                    )}\n\n                    {item.icon && <item.icon className=\"h-3.5 w-3.5\" />}\n                    <span>{item.label}</span>\n\n                    {item.badge && (\n                      <span className=\"rounded-full bg-neutral-200/80 px-1.5 py-0.2 text-[10px] font-semibold text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300\">\n                        {item.badge}\n                      </span>\n                    )}\n\n                    {hasDropdown && (\n                      <ChevronDown\n                        className={cn(\n                          \"h-3 w-3 transition-transform duration-200\",\n                          isDropdownOpen ? \"rotate-180\" : \"\"\n                        )}\n                      />\n                    )}\n                  </a>\n\n                  {/* Dropdown Menu */}\n                  {hasDropdown && (\n                    <AnimatePresence>\n                      {isDropdownOpen && (\n                        <motion.div\n                          initial={\n                            shouldReduceMotion\n                              ? { opacity: 0 }\n                              : { opacity: 0, y: 8, scale: 0.96 }\n                          }\n                          animate={\n                            shouldReduceMotion\n                              ? { opacity: 1 }\n                              : { opacity: 1, y: 0, scale: 1 }\n                          }\n                          exit={\n                            shouldReduceMotion\n                              ? { opacity: 0 }\n                              : { opacity: 0, y: 6, scale: 0.96 }\n                          }\n                          transition={{\n                            type: \"spring\",\n                            stiffness: 450,\n                            damping: 30,\n                          }}\n                          className=\"absolute left-0 top-full pt-2 w-72 z-50\"\n                        >\n                          <div className=\"overflow-hidden rounded-xl border border-neutral-200/90 bg-white p-2 shadow-xl shadow-neutral-900/10 backdrop-blur-xl dark:border-neutral-800 dark:bg-neutral-900/95 dark:shadow-black/30\">\n                            {item.children!.map((subItem) => (\n                              <a\n                                key={subItem.label}\n                                href={subItem.href}\n                                onClick={(e) => {\n                                  e.preventDefault();\n                                  handleItemClick(subItem.href);\n                                }}\n                                className=\"group flex items-start gap-3 rounded-lg p-2.5 transition-colors hover:bg-neutral-100/80 dark:hover:bg-neutral-800/70\"\n                              >\n                                {subItem.icon && (\n                                  <div className=\"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-neutral-200/70 bg-neutral-50 text-neutral-600 transition-colors group-hover:border-neutral-400 group-hover:text-neutral-950 dark:border-neutral-700 dark:bg-neutral-800/80 dark:text-neutral-300 dark:group-hover:text-white\">\n                                    <subItem.icon className=\"h-3.5 w-3.5\" />\n                                  </div>\n                                )}\n                                <div className=\"flex-1 min-w-0\">\n                                  <div className=\"flex items-center gap-1.5\">\n                                    <span className=\"text-xs font-semibold text-neutral-900 dark:text-white\">\n                                      {subItem.label}\n                                    </span>\n                                    {subItem.badge && (\n                                      <span className=\"rounded bg-neutral-100 px-1 py-0.5 text-[9px] font-medium text-neutral-600 dark:bg-neutral-800 dark:text-neutral-300\">\n                                        {subItem.badge}\n                                      </span>\n                                    )}\n                                  </div>\n                                  {subItem.description && (\n                                    <p className=\"mt-0.5 text-[11px] leading-snug text-neutral-500 line-clamp-2 dark:text-neutral-400\">\n                                      {subItem.description}\n                                    </p>\n                                  )}\n                                </div>\n                              </a>\n                            ))}\n                          </div>\n                        </motion.div>\n                      )}\n                    </AnimatePresence>\n                  )}\n                </div>\n              );\n            })}\n          </div>\n\n          {/* Action CTAs */}\n          <div className=\"hidden md:flex items-center gap-2\">\n            {actions.map((action) => {\n              const Icon = action.icon;\n              return (\n                <button\n                  key={action.label}\n                  type=\"button\"\n                  onClick={action.onClick}\n                  className={cn(\n                    \"relative inline-flex items-center justify-center gap-1.5 rounded-lg px-3.5 py-1.5 text-xs font-medium transition-all active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 dark:focus-visible:ring-neutral-600\",\n                    action.variant === \"primary\"\n                      ? \"bg-neutral-950 text-white shadow hover:bg-neutral-800 dark:bg-white dark:text-neutral-950 dark:hover:bg-neutral-200\"\n                      : action.variant === \"secondary\"\n                      ? \"border border-neutral-300/80 bg-white text-neutral-900 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800\"\n                      : \"text-neutral-600 hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\"\n                  )}\n                >\n                  {Icon && <Icon className=\"h-3.5 w-3.5\" />}\n                  <span>{action.label}</span>\n                </button>\n              );\n            })}\n          </div>\n\n          {/* Mobile Hamburger Toggle */}\n          <div className=\"flex md:hidden items-center gap-2\">\n            <button\n              type=\"button\"\n              onClick={() => setMobileMenuOpen((prev) => !prev)}\n              aria-label={mobileMenuOpen ? \"Close menu\" : \"Open menu\"}\n              aria-expanded={mobileMenuOpen}\n              className=\"flex h-8 w-8 items-center justify-center rounded-lg border border-neutral-200 bg-neutral-50 text-neutral-700 transition-colors hover:bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:bg-neutral-800\"\n            >\n              {mobileMenuOpen ? (\n                <X className=\"h-4 w-4\" />\n              ) : (\n                <Menu className=\"h-4 w-4\" />\n              )}\n            </button>\n          </div>\n        </div>\n\n        {/* Mobile Slide-down Drawer */}\n        <AnimatePresence>\n          {mobileMenuOpen && (\n            <motion.div\n              initial={\n                shouldReduceMotion\n                  ? { opacity: 0 }\n                  : { opacity: 0, height: 0, y: -8 }\n              }\n              animate={\n                shouldReduceMotion\n                  ? { opacity: 1 }\n                  : { opacity: 1, height: \"auto\", y: 0 }\n              }\n              exit={\n                shouldReduceMotion\n                  ? { opacity: 0 }\n                  : { opacity: 0, height: 0, y: -8 }\n              }\n              transition={{ type: \"spring\", stiffness: 350, damping: 28 }}\n              className=\"overflow-hidden md:hidden pt-3 border-t border-neutral-200/70 mt-3 dark:border-neutral-800/80\"\n            >\n              <div className=\"flex flex-col gap-1 pb-2\">\n                {items.map((item) => {\n                  const isActive = currentActive === item.href;\n                  return (\n                    <div key={item.label} className=\"flex flex-col\">\n                      <a\n                        href={item.href}\n                        onClick={(e) => {\n                          e.preventDefault();\n                          handleItemClick(item.href);\n                        }}\n                        className={cn(\n                          \"flex items-center justify-between rounded-lg px-3 py-2 text-xs font-medium transition-colors\",\n                          isActive\n                            ? \"bg-neutral-100 font-semibold text-neutral-950 dark:bg-neutral-800 dark:text-white\"\n                            : \"text-neutral-600 hover:bg-neutral-50 hover:text-neutral-950 dark:text-neutral-400 dark:hover:bg-neutral-900 dark:hover:text-white\"\n                        )}\n                      >\n                        <div className=\"flex items-center gap-2\">\n                          {item.icon && <item.icon className=\"h-3.5 w-3.5\" />}\n                          <span>{item.label}</span>\n                        </div>\n                        {item.badge && (\n                          <span className=\"rounded bg-neutral-200 px-1.5 py-0.5 text-[9px] font-semibold text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300\">\n                            {item.badge}\n                          </span>\n                        )}\n                      </a>\n\n                      {/* Mobile Sub-items */}\n                      {item.children && (\n                        <div className=\"ml-4 flex flex-col gap-1 border-l border-neutral-200 pl-2 my-1 dark:border-neutral-800\">\n                          {item.children.map((subItem) => (\n                            <a\n                              key={subItem.label}\n                              href={subItem.href}\n                              onClick={(e) => {\n                                e.preventDefault();\n                                handleItemClick(subItem.href);\n                              }}\n                              className=\"rounded-md px-2 py-1.5 text-[11px] text-neutral-500 hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\"\n                            >\n                              {subItem.label}\n                            </a>\n                          ))}\n                        </div>\n                      )}\n                    </div>\n                  );\n                })}\n\n                <div className=\"mt-3 flex flex-col gap-2 pt-2 border-t border-neutral-200/60 dark:border-neutral-800/70\">\n                  {actions.map((action) => (\n                    <button\n                      key={action.label}\n                      type=\"button\"\n                      onClick={() => {\n                        action.onClick?.();\n                        setMobileMenuOpen(false);\n                      }}\n                      className={cn(\n                        \"w-full rounded-lg py-2 text-center text-xs font-medium transition-all active:scale-98\",\n                        action.variant === \"primary\"\n                          ? \"bg-neutral-950 text-white dark:bg-white dark:text-neutral-950\"\n                          : \"border border-neutral-300/80 bg-white text-neutral-800 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200\"\n                      )}\n                    >\n                      {action.label}\n                    </button>\n                  ))}\n                </div>\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </nav>\n    </header>\n  );\n}\n\nexport default Navbar;\n",
      "type": "registry:ui",
      "target": "components/ui/navbar.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
