{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar",
  "type": "registry:ui",
  "title": "Sidebar",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Collapsible kinetic navigation sidebar with spring layout expansion, active selection capsule, popout hover tooltips, and nested sub-items.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/sidebar.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useId } from \"react\";\nimport { motion, AnimatePresence, useReducedMotion, type HTMLMotionProps } from \"framer-motion\";\nimport {\n  ChevronLeft,\n  ChevronRight,\n  ChevronDown,\n  LayoutDashboard,\n  Layers,\n  BarChart3,\n  Settings,\n  Users,\n  FolderGit2,\n  Bell,\n  Sparkles,\n  LogOut,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SidebarSubItem {\n  id: string;\n  label: string;\n  href: string;\n  badge?: string | number;\n}\n\nexport interface SidebarItem {\n  id: string;\n  label: string;\n  href: string;\n  icon: React.ComponentType<{ className?: string }>;\n  badge?: string | number;\n  badgeVariant?: \"default\" | \"brand\" | \"success\" | \"warning\";\n  children?: SidebarSubItem[];\n}\n\nexport interface SidebarSection {\n  title?: string;\n  items: SidebarItem[];\n}\n\nexport interface SidebarUser {\n  name: string;\n  role?: string;\n  avatarUrl?: string;\n  email?: string;\n}\n\nexport interface SidebarProps\n  extends Omit<HTMLMotionProps<\"aside\">, \"children\" | \"header\" | \"footer\"> {\n  children?: React.ReactNode;\n  /** Grouped sections of navigation items */\n  sections?: SidebarSection[];\n  /** Controlled active item id */\n  activeId?: string;\n  /** Initial active item id for uncontrolled usage */\n  defaultActiveId?: string;\n  /** Controlled collapsed state */\n  collapsed?: boolean;\n  /** Initial collapsed state */\n  defaultCollapsed?: boolean;\n  /** Callback fired when collapsed state toggles */\n  onCollapsedChange?: (collapsed: boolean) => void;\n  /** Callback fired when an item is clicked */\n  onItemSelect?: (item: SidebarItem) => void;\n  /** User profile card details for the sidebar footer */\n  user?: SidebarUser;\n  /** Custom header slot */\n  header?: React.ReactNode;\n  /** Custom footer slot */\n  footer?: React.ReactNode;\n  /** Whether the sidebar collapse toggle is enabled */\n  collapsible?: boolean;\n  /** Optional custom class name */\n  className?: string;\n}\n\nconst DEFAULT_SECTIONS: SidebarSection[] = [\n  {\n    title: \"Platform\",\n    items: [\n      {\n        id: \"dashboard\",\n        label: \"Overview\",\n        href: \"#overview\",\n        icon: LayoutDashboard,\n      },\n      {\n        id: \"components\",\n        label: \"Primitives\",\n        href: \"#primitives\",\n        icon: Layers,\n        badge: \"106+\",\n        badgeVariant: \"brand\",\n        children: [\n          { id: \"comp-nav\", label: \"Navigation\", href: \"#navigation\" },\n          { id: \"comp-motion\", label: \"Motion\", href: \"#motion\" },\n          { id: \"comp-cards\", label: \"Cards\", href: \"#cards\" },\n        ],\n      },\n      {\n        id: \"analytics\",\n        label: \"Analytics\",\n        href: \"#analytics\",\n        icon: BarChart3,\n      },\n      {\n        id: \"projects\",\n        label: \"Workspaces\",\n        href: \"#workspaces\",\n        icon: FolderGit2,\n        badge: \"3\",\n      },\n    ],\n  },\n  {\n    title: \"Account\",\n    items: [\n      {\n        id: \"team\",\n        label: \"Collaborators\",\n        href: \"#team\",\n        icon: Users,\n      },\n      {\n        id: \"notifications\",\n        label: \"Notifications\",\n        href: \"#notifications\",\n        icon: Bell,\n        badge: \"4\",\n        badgeVariant: \"warning\",\n      },\n      {\n        id: \"settings\",\n        label: \"Preferences\",\n        href: \"#preferences\",\n        icon: Settings,\n      },\n    ],\n  },\n];\n\nconst DEFAULT_USER: SidebarUser = {\n  name: \"Alex Vance\",\n  role: \"Design Engineer\",\n  email: \"alex@boseui.site\",\n};\n\nexport function Sidebar({\n  sections = DEFAULT_SECTIONS,\n  activeId: controlledActiveId,\n  defaultActiveId = \"dashboard\",\n  collapsed: controlledCollapsed,\n  defaultCollapsed = false,\n  onCollapsedChange,\n  onItemSelect,\n  user = DEFAULT_USER,\n  header,\n  footer,\n  collapsible = true,\n  className,\n  ...props\n}: SidebarProps) {\n  const [internalActiveId, setInternalActiveId] = useState(defaultActiveId);\n  const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed);\n  const [expandedSubmenus, setExpandedSubmenus] = useState<Record<string, boolean>>({\n    components: true,\n  });\n  const [hoveredTooltip, setHoveredTooltip] = useState<string | null>(null);\n\n  const shouldReduceMotion = useReducedMotion();\n  const instanceId = useId();\n\n  const isCollapsed =\n    controlledCollapsed !== undefined ? controlledCollapsed : internalCollapsed;\n  const currentActiveId =\n    controlledActiveId !== undefined ? controlledActiveId : internalActiveId;\n\n  const toggleCollapse = () => {\n    const next = !isCollapsed;\n    if (controlledCollapsed === undefined) {\n      setInternalCollapsed(next);\n    }\n    onCollapsedChange?.(next);\n  };\n\n  const handleItemClick = (item: SidebarItem) => {\n    if (item.children && !isCollapsed) {\n      setExpandedSubmenus((prev) => ({\n        ...prev,\n        [item.id]: !prev[item.id],\n      }));\n    }\n    if (controlledActiveId === undefined) {\n      setInternalActiveId(item.id);\n    }\n    onItemSelect?.(item);\n  };\n\n  return (\n    <motion.aside\n      aria-label=\"Application Sidebar\"\n      animate={{ width: isCollapsed ? 72 : 260 }}\n      transition={\n        shouldReduceMotion\n          ? { duration: 0 }\n          : { type: \"spring\", stiffness: 350, damping: 32 }\n      }\n      className={cn(\n        \"relative flex h-full min-h-[560px] flex-col justify-between border-r border-neutral-200/80 bg-white/95 p-3 text-neutral-900 shadow-sm backdrop-blur-xl dark:border-neutral-800/80 dark:bg-neutral-950/95 dark:text-neutral-100\",\n        className\n      )}\n      {...props}\n    >\n      {/* Top Header Slot */}\n      <div>\n        <div className=\"flex h-12 items-center justify-between px-2\">\n          {header || (\n            <div className=\"flex items-center gap-3 overflow-hidden\">\n              <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-neutral-950 text-white shadow-sm dark:bg-white dark:text-neutral-950\">\n                <Sparkles className=\"h-4 w-4\" />\n              </div>\n              <AnimatePresence>\n                {!isCollapsed && (\n                  <motion.div\n                    initial={{ opacity: 0, x: -10 }}\n                    animate={{ opacity: 1, x: 0 }}\n                    exit={{ opacity: 0, x: -10 }}\n                    transition={{ duration: 0.15 }}\n                    className=\"flex flex-col overflow-hidden whitespace-nowrap\"\n                  >\n                    <span className=\"text-sm font-bold tracking-tight text-neutral-950 dark:text-white\">\n                      BoseUI Studio\n                    </span>\n                    <span className=\"text-[10px] text-neutral-500 font-mono\">\n                      v2.0 Pro System\n                    </span>\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </div>\n          )}\n\n          {collapsible && (\n            <button\n              type=\"button\"\n              onClick={toggleCollapse}\n              aria-label={isCollapsed ? \"Expand sidebar\" : \"Collapse sidebar\"}\n              className={cn(\n                \"flex h-7 w-7 items-center justify-center rounded-md border border-neutral-200 bg-neutral-50 text-neutral-600 transition-colors hover:bg-neutral-100 hover:text-neutral-950 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-white\",\n                isCollapsed && \"absolute -right-3 h-5 w-5\"\n              )}\n            >\n              {isCollapsed ? (\n                <ChevronRight className=\"h-3.5 w-3.5\" />\n              ) : (\n                <ChevronLeft className=\"h-3.5 w-3.5\" />\n              )}\n            </button>\n          )}\n        </div>\n\n        {/* Navigation Sections */}\n        <div className=\"mt-4 flex flex-col gap-5 overflow-y-auto overflow-x-hidden\">\n          {sections.map((section, sIdx) => (\n            <div key={section.title || `sec-${sIdx}`} className=\"flex flex-col gap-1\">\n              {section.title && !isCollapsed && (\n                <span className=\"px-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-neutral-400 dark:text-neutral-500\">\n                  {section.title}\n                </span>\n              )}\n\n              {section.items.map((item) => {\n                const Icon = item.icon;\n                const isActive = currentActiveId === item.href || currentActiveId === item.id;\n                const hasChildren = Boolean(item.children && item.children.length > 0);\n                const isSubmenuOpen = Boolean(expandedSubmenus[item.id]);\n\n                return (\n                  <div key={item.id} className=\"relative\">\n                    <button\n                      type=\"button\"\n                      onClick={() => handleItemClick(item)}\n                      onMouseEnter={() => {\n                        if (isCollapsed) setHoveredTooltip(item.id);\n                      }}\n                      onMouseLeave={() => setHoveredTooltip(null)}\n                      aria-current={isActive ? \"page\" : undefined}\n                      className={cn(\n                        \"group relative flex w-full items-center gap-3 rounded-lg px-2.5 py-2 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 dark:text-white font-semibold\"\n                          : \"text-neutral-600 hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\",\n                        isCollapsed ? \"justify-center px-0\" : \"\"\n                      )}\n                    >\n                      {/* Active Spring Capsule Indicator */}\n                      {isActive && (\n                        <motion.div\n                          layoutId={`sidebar-active-${instanceId}`}\n                          className=\"absolute inset-0 rounded-lg bg-neutral-100/90 dark:bg-neutral-800/80 -z-10 shadow-sm\"\n                          transition={{\n                            type: \"spring\",\n                            stiffness: 400,\n                            damping: 30,\n                          }}\n                        />\n                      )}\n\n                      <Icon\n                        className={cn(\n                          \"h-4 w-4 shrink-0 transition-transform group-hover:scale-105\",\n                          isActive\n                            ? \"text-neutral-950 dark:text-white\"\n                            : \"text-neutral-500 dark:text-neutral-400\"\n                        )}\n                      />\n\n                      {!isCollapsed && (\n                        <div className=\"flex flex-1 items-center justify-between overflow-hidden\">\n                          <span className=\"truncate\">{item.label}</span>\n\n                          <div className=\"flex items-center gap-1.5 ml-2\">\n                            {item.badge && (\n                              <span\n                                className={cn(\n                                  \"rounded px-1.5 py-0.2 text-[9px] font-semibold\",\n                                  item.badgeVariant === \"brand\"\n                                    ? \"bg-neutral-950 text-white dark:bg-white dark:text-neutral-950\"\n                                    : item.badgeVariant === \"warning\"\n                                      ? \"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300\"\n                                      : \"bg-neutral-200 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300\"\n                                )}\n                              >\n                                {item.badge}\n                              </span>\n                            )}\n\n                            {hasChildren && (\n                              <ChevronDown\n                                className={cn(\n                                  \"h-3 w-3 text-neutral-400 transition-transform duration-200\",\n                                  isSubmenuOpen ? \"rotate-180\" : \"\"\n                                )}\n                              />\n                            )}\n                          </div>\n                        </div>\n                      )}\n                    </button>\n\n                    {/* Popout Tooltip in Collapsed Mode */}\n                    {isCollapsed && hoveredTooltip === item.id && (\n                      <motion.div\n                        initial={{ opacity: 0, x: 8, scale: 0.95 }}\n                        animate={{ opacity: 1, x: 0, scale: 1 }}\n                        exit={{ opacity: 0, x: 8, scale: 0.95 }}\n                        transition={{ duration: 0.15 }}\n                        className=\"pointer-events-none absolute left-full top-1/2 z-50 ml-3 -translate-y-1/2 whitespace-nowrap rounded-md border border-neutral-200 bg-neutral-900 px-2.5 py-1 text-xs font-medium text-white shadow-lg dark:border-neutral-800 dark:bg-neutral-800\"\n                      >\n                        <div className=\"flex items-center gap-2\">\n                          <span>{item.label}</span>\n                          {item.badge && (\n                            <span className=\"rounded bg-neutral-800 px-1 py-0.2 text-[9px] font-semibold text-neutral-300 dark:bg-neutral-700\">\n                              {item.badge}\n                            </span>\n                          )}\n                        </div>\n                      </motion.div>\n                    )}\n\n                    {/* Expandable Sub-items */}\n                    {!isCollapsed && hasChildren && isSubmenuOpen && (\n                      <AnimatePresence>\n                        <motion.div\n                          initial={{ opacity: 0, height: 0 }}\n                          animate={{ opacity: 1, height: \"auto\" }}\n                          exit={{ opacity: 0, height: 0 }}\n                          transition={{ type: \"spring\", stiffness: 350, damping: 28 }}\n                          className=\"ml-6 flex flex-col gap-0.5 border-l border-neutral-200 pl-3 my-1 dark:border-neutral-800\"\n                        >\n                          {item.children!.map((sub) => {\n                            const isSubActive =\n                              currentActiveId === sub.href || currentActiveId === sub.id;\n                            return (\n                              <a\n                                key={sub.id}\n                                href={sub.href}\n                                onClick={(e) => {\n                                  e.preventDefault();\n                                  setInternalActiveId(sub.id);\n                                }}\n                                className={cn(\n                                  \"flex items-center justify-between rounded-md px-2 py-1.5 text-[11px] transition-colors\",\n                                  isSubActive\n                                    ? \"bg-neutral-100 font-semibold text-neutral-950 dark:bg-neutral-800/70 dark:text-white\"\n                                    : \"text-neutral-500 hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\"\n                                )}\n                              >\n                                <span>{sub.label}</span>\n                                {sub.badge && (\n                                  <span className=\"text-[9px] text-neutral-400\">\n                                    {sub.badge}\n                                  </span>\n                                )}\n                              </a>\n                            );\n                          })}\n                        </motion.div>\n                      </AnimatePresence>\n                    )}\n                  </div>\n                );\n              })}\n            </div>\n          ))}\n        </div>\n      </div>\n\n      {/* Bottom User Card Slot */}\n      <div className=\"border-t border-neutral-200/70 pt-3 dark:border-neutral-800/70\">\n        {footer || (\n          <div\n            className={cn(\n              \"flex items-center gap-3 rounded-xl p-1.5 transition-colors hover:bg-neutral-100/80 dark:hover:bg-neutral-900/80\",\n              isCollapsed ? \"justify-center p-0\" : \"\"\n            )}\n          >\n            <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-neutral-200 text-xs font-bold text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300\">\n              {user.avatarUrl ? (\n                <img\n                  src={user.avatarUrl}\n                  alt={user.name}\n                  className=\"h-full w-full rounded-full object-cover\"\n                />\n              ) : (\n                user.name.charAt(0)\n              )}\n            </div>\n\n            {!isCollapsed && (\n              <div className=\"flex flex-1 items-center justify-between overflow-hidden\">\n                <div className=\"flex flex-col truncate\">\n                  <span className=\"truncate text-xs font-semibold text-neutral-900 dark:text-white\">\n                    {user.name}\n                  </span>\n                  <span className=\"truncate text-[10px] text-neutral-500 dark:text-neutral-400\">\n                    {user.role || user.email}\n                  </span>\n                </div>\n\n                <button\n                  type=\"button\"\n                  aria-label=\"Log out\"\n                  className=\"rounded-md p-1 text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200\"\n                >\n                  <LogOut className=\"h-3.5 w-3.5\" />\n                </button>\n              </div>\n            )}\n          </div>\n        )}\n      </div>\n    </motion.aside>\n  );\n}\n\nexport default Sidebar;\n",
      "type": "registry:ui",
      "target": "components/ui/sidebar.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"
    }
  ]
}
