{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sidebar",
  "title": "Sidebar",
  "description": "The column of links down the side of an app, in sections, with the current page marked `aria-current=\"page\"` and a bar at the start edge, distinct from hover and press highlights.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-current-path",
    "@ouro/lib-env",
    "@ouro/lib-router-link",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-media-query",
    "@ouro/menu",
    "@ouro/sheet",
    "@ouro/tooltip"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/sidebar/sidebar.tsx",
      "content": "\"use client\";\n\nimport { useId, useRef, useState, type JSX, type MouseEvent, type ReactElement, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { currentHref } from \"@/registry/ouro/lib/ouro/current-path\";\nimport { RouterLink } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useMediaQuery } from \"@/registry/ouro/lib/ouro/use-media-query\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport { Menu, MenuItem } from \"@/registry/ouro/components/ouro/menu/menu\";\nimport { SheetFrame } from \"@/registry/ouro/components/ouro/sheet/sheet\";\nimport { Tooltip } from \"@/registry/ouro/components/ouro/tooltip/tooltip\";\n\n/**\n * What every Sidebar item has: its text, an icon and a badge.\n *\n * @claim \"What every Sidebar item has: its\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar items > shows a badge after the label, read as part of the link's name, and keeps it in the name on the rail)\n * @claim \"What every Sidebar item has: its\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the icons from screen readers)\n * @claim \"What every Sidebar item has: its\" registry/ouro/components/ouro/sidebar/sidebar.test-d.ts verify:fileLine(registry/ouro/components/ouro/sidebar/sidebar.test-d.ts, /expectTypeOf<\\{\\slabel:\\s\"New\\schat\";\\sonClick:\\s\\(\\)\\s=>\\svoid;\\scurrent:\\strue\\s\\}>\\(\\)\\.not\\.toExtend<SidebarItem>/)\n */\ninterface SidebarItemBase {\n  /** The item's text: \"Recipes\". It stays the item's name when the sidebar is collapsed. */\n  label: string;\n  /**\n   * An icon before the label, as an element: `icon: <BookIcon />`. It is hidden from screen\n   * readers. Collapsed, the sidebar shows only the icons; an item without one shows its\n   * first letter.\n   */\n  icon?: ReactNode;\n  /**\n   * A short count or tag after the label: `badge: 12`, `badge: \"New\"`. It is read as part of\n   * the item's name, and hidden from sight when the sidebar is collapsed.\n   */\n  badge?: ReactNode;\n}\n\n/** A link in a Sidebar. */\nexport interface SidebarLinkItem extends SidebarItemBase {\n  /** Where it goes. Internal paths go through `OuroProvider`'s `linkComponent` (your router's link). */\n  href: string;\n  /**\n   * Marks this link as the current page (`aria-current=\"page\"`), when the Sidebar's\n   * `currentPath` cannot tell: a link whose page lives at another path.\n   */\n  current?: boolean | undefined;\n  /** Called when the link is followed, before your router navigates. */\n  onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;\n  /** Not with `href`. Nested links go in an item without `href`: `{ label: \"Settings\", items: [...] }`. */\n  items?: never;\n}\n\n/** A button in a Sidebar, for an action rather than a page: \"New chat\", \"Search\" opening a `Command`. */\nexport interface SidebarButtonItem extends SidebarItemBase {\n  /** What the button does. In the phone's drawer, the drawer closes first. */\n  onClick: (event: MouseEvent<HTMLElement>) => void;\n  /** Not with `onClick` alone. Give a link `href`; a button has none. */\n  href?: never;\n  /** Not on a button. Only a link can be the current page. */\n  current?: never;\n  /** Not on a button. Nested links go in an item without `onClick`: `{ label: \"Settings\", items: [...] }`. */\n  items?: never;\n}\n\n/**\n * An item with links nested under it, one level deep: a button that shows and hides them.\n * It starts open when it holds the current page. On the collapsed rail the button opens\n * them in a `Menu` beside it.\n */\nexport interface SidebarGroupItem extends SidebarItemBase {\n  /** The nested links and buttons. They do not nest further. */\n  items: readonly (SidebarLinkItem | SidebarButtonItem)[];\n  /** Not with `items`. To link the group's own page, make it the group's first item. */\n  href?: never;\n  /** Not with `items`; the group's button shows and hides them. */\n  onClick?: never;\n  /** Not on a group. One of its links is the current page. */\n  current?: never;\n}\n\n/** One item of a Sidebar: a link (`href`), a button (`onClick`), or links nested under a button (`items`). */\nexport type SidebarItem = SidebarLinkItem | SidebarButtonItem | SidebarGroupItem;\n\n/** A group of links in a Sidebar, under an optional label. */\nexport interface SidebarSection {\n  /** The group's name, shown above its links: \"Library\". */\n  label?: string | undefined;\n  /** The group's items, in order: links, buttons and nested links. */\n  items: readonly SidebarItem[];\n}\n\n/** Props for {@link Sidebar}. */\nexport interface SidebarProps {\n  /** Names the navigation for screen readers (\"Main\"). It is not shown. */\n  label: string;\n  /** The links, in groups: `sections={[{ items: [...] }, { label: \"Library\", items: [...] }]}`. */\n  sections: readonly SidebarSection[];\n  /**\n   * The path of the page being shown, from your router (`useLocation().pathname`, or\n   * `usePathname()` in Next.js). The link to that path, or else the longest link above it\n   * (`/recipes` for `/recipes/12`), gets `aria-current=\"page\"` and the current look.\n   */\n  currentPath?: string | undefined;\n  /** Above the links: your logo, product name or a workspace `Menu`. Clipped to the rail when collapsed. */\n  header?: ReactNode;\n  /** Below the links: the signed-in person, an account `Menu`. Clipped to the rail when collapsed. */\n  footer?: ReactNode;\n  /**\n   * Whether the sidebar has a button that collapses it to a rail of icons, from 640px up.\n   * @default true\n   * @claim \"Whether the sidebar has a button\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > collapses to a rail of icons with the toggle, keeping each link's name)\n   * @claim \"Whether the sidebar has a button\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the menu button from 640px up)\n   */\n  collapsible?: boolean | undefined;\n  /** Whether the sidebar is collapsed, when you control it (to remember it). Pair it with `onCollapsedChange`. */\n  collapsed?: boolean | undefined;\n  /** Whether the sidebar starts collapsed, when it keeps its own state. @default false */\n  defaultCollapsed?: boolean | undefined;\n  /** Called with the new state when the person collapses or expands the sidebar. */\n  onCollapsedChange?: ((collapsed: boolean) => void) | undefined;\n  /** The collapse button's name and text; `aria-pressed` says whether it is on. @default \"Collapse sidebar\" */\n  collapseLabel?: string | undefined;\n  /**\n   * Below 640px: the name of the button that opens the sidebar as a drawer, and the\n   * drawer's title (shown when there is no `header`). @default \"Menu\"\n   * @claim \"Below 640px: the name of the\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n   * @claim \"Below 640px: the name of the\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the menu button from 640px up)\n   * @claim \"Below 640px: the name of the\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > closes the drawer when the screen grows past 640px)\n   */\n  menuLabel?: string | undefined;\n  /** The label of the drawer's close button. @default \"Close\" */\n  closeLabel?: string | undefined;\n  /** Layout only: grid placement and margins (`row-span-2`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. Links go in `sections`: `sections={[{ items: [{ label: \"Recipes\", href: \"/recipes\" }] }]}`. */\n  items?: { 'Use sections={[{ items: [{ label: \"Recipes\", href: \"/recipes\" }] }]}': never };\n  /** Not a prop. Ouro UI uses `collapsed` with `onCollapsedChange`, or `defaultCollapsed`. */\n  isCollapsed?: { \"Use <Sidebar collapsed={collapsed} onCollapsedChange={setCollapsed}>\": never };\n  /** Not a prop. Ouro UI uses `currentPath`: `<Sidebar currentPath={pathname}>`. */\n  pathname?: { \"Use <Sidebar currentPath={pathname}>\": never };\n  /** Not rendered. The sidebar is `sections`, `header` and `footer`. */\n  children?: { \"Use sections={[{ items: [{ label, href }] }]}, header={...} and footer={...}\": never };\n}\n\n// Class strings are literal so the app's Tailwind finds them when it compiles.\n\n// The column: --ouro-sidebar-w, which the app may set on the Sidebar or around it, else 16rem; or a rail (a 44px target,\n// its padding and the border) when collapsed. The width changes at once: layout does not animate.\nconst column =\n  \"box-border flex h-full w-[var(--ouro-sidebar-w,16rem)] flex-col overflow-hidden border-0 border-e border-solid border-border bg-background text-foreground \" +\n  \"data-collapsed:w-[calc(3.75rem+1px)] max-sm:hidden\";\n\n// A count or tag at the row's end. Its muted text is mixed 20% toward the foreground, so it keeps\n// 4.5:1 on the muted tag under shadcn's stock values too (plain text-muted-foreground is 4.34:1).\nconst badgeClass = \"ms-auto shrink-0 rounded-ouro-sm bg-muted px-1.5 text-xs leading-5 font-medium text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))] tabular-nums\";\n\n// A row: 44px with 16px text on a coarse pointer at every width, 36px with 14px text with a\n// fine one. A full-width row highlights while pressed instead of scaling.\nconst row =\n  \"relative m-0 box-border flex w-full min-h-11 pointer-fine:min-h-9 cursor-pointer items-center gap-3 rounded-ouro-md border-0 forced-colors:border forced-colors:border-solid bg-transparent px-3 py-2 \" +\n  \"text-start font-[inherit] text-base pointer-fine:text-sm leading-5 font-medium text-muted-foreground no-underline select-none touch-manipulation \" +\n  \"[-webkit-tap-highlight-color:transparent] transition-colors duration-(--ouro-duration-fast) ease-[ease] \" +\n  \"pointer-fine:hover:bg-accent pointer-fine:hover:text-accent-foreground active:bg-accent active:text-accent-foreground \" +\n  \"aria-[current=page]:font-semibold aria-[current=page]:text-foreground \" +\n  \"aria-[current=page]:before:absolute aria-[current=page]:before:inset-y-2 aria-[current=page]:before:start-0 aria-[current=page]:before:w-0.5 aria-[current=page]:before:rounded-full aria-[current=page]:before:bg-current aria-[current=page]:before:content-[''] \" +\n  \"forced-colors:aria-[current=page]:before:border-s-2 forced-colors:aria-[current=page]:before:border-solid forced-colors:aria-[current=page]:before:border-current \" +\n  \"outline-ring -outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\nconst railRow = \"justify-center px-0\";\nconst iconSlot = \"flex size-5 shrink-0 items-center justify-center text-sm [&_svg]:size-5 [&_svg]:shrink-0\";\nconst list = \"m-0 grid list-none gap-1 p-0\";\nconst example = '<Sidebar label=\"Main\" sections={[{ items: [{ label: \"Recipes\", href: \"/recipes\" }] }]}';\n\n/**\n * The column of links down the side of an app, in sections, with the current page marked\n * `aria-current=\"page\"` and a bar at the start edge, distinct from hover and press highlights. An item can carry a `badge` (\"Inbox 12\"), be a button (`onClick`\n * without `href`), or hold one level of nested links (`items`). From 640px up it fills its\n * container's height and collapses to a rail of icons with its own button, each named by a\n * `Tooltip`, where an item with nested links opens them in a `Menu`; below 640px it is a menu button that opens the same links as a `Sheet`\n * drawer. Links render through `OuroProvider`'s `linkComponent`, so your router navigates.\n * It is 16rem wide; set `--ouro-sidebar-w` on it or around it for another width (`className=\"[--ouro-sidebar-w:12rem]\"`).\n *\n * The phone menu opens once JavaScript has loaded (after hydration);\n * the links are in the server HTML from 640px up.\n *\n * Put it in a `SidebarLayout`, which places it beside the page and in the phone's top bar.\n * Use `Navbar` instead for a handful of links across the top, `NavigationRail` for a narrow bar\n * of the app's top-level pages, each an icon over its label, and `Tabs` for views of one page.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/sidebar\n *\n * @example\n * <Sidebar\n *   label=\"Main\"\n *   header={<Link href=\"/\">Spoonjoy</Link>}\n *   sections={[\n *     { items: [{ label: \"Recipes\", href: \"/recipes\", icon: <BookIcon /> }] },\n *     { label: \"Library\", items: [{ label: \"Cookbooks\", href: \"/cookbooks\", icon: <StackIcon /> }] },\n *   ]}\n *   currentPath={pathname}\n * />\n * @claim \"From 640px up it fills its\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > becomes a menu button that opens a drawer below 640px)\n * @claim \"From 640px up it fills its\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > hides the menu button from 640px up)\n * @claim \"From 640px up it fills its\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > closes the drawer when the screen grows past 640px)\n * @claim \"It is 16rem wide; set `--ouro-sidebar-w`\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > takes its width from --ouro-sidebar-w, set on it or around it, and is still a rail when collapsed)\n * @claim \"The phone menu opens once JavaScript\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > puts the nav and its links in the server HTML)\n */\nexport function Sidebar(props: SidebarProps): JSX.Element {\n  const {\n    label,\n    sections,\n    currentPath,\n    header,\n    footer,\n    collapsible = true,\n    collapsed: collapsedProp,\n    defaultCollapsed = false,\n    onCollapsedChange,\n    collapseLabel = \"Collapse sidebar\",\n    menuLabel = \"Menu\",\n    closeLabel = \"Close\",\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    items,\n    isCollapsed,\n    pathname,\n    children,\n  } = props;\n  useAppearanceClassNameCheck(\n    \"Sidebar\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; Sidebar sets its own look`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  const group = sections.flatMap((section) => section.items).find((item) => item.items !== undefined);\n  useDevWarnings(\n    \"Sidebar\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !label && [\"label is required; it names the navigation for screen readers\", '<Sidebar label=\"Main\">'],\n          collapsedProp !== undefined &&\n            collapsible &&\n            onCollapsedChange === undefined && [\n              \"collapsed without onCollapsedChange cannot be toggled\",\n              \"<Sidebar collapsed={collapsed} onCollapsedChange={setCollapsed}> or defaultCollapsed\",\n            ],\n          collapsedProp === true &&\n            onCollapsedChange === undefined &&\n            group !== undefined && [\n              `collapsed without onCollapsedChange cannot expand, so \"${group.label}\" shows its links only in a menu`,\n              \"<Sidebar collapsed={collapsed} onCollapsedChange={setCollapsed}> or defaultCollapsed\",\n            ],\n          items !== undefined && [\"items is not a prop; links go in sections\", `${example} />`],\n          isCollapsed !== undefined && [\"isCollapsed is not a prop\", \"<Sidebar collapsed={collapsed} onCollapsedChange={setCollapsed}>\"],\n          pathname !== undefined && [\"pathname is not a prop\", \"<Sidebar currentPath={pathname}>\"],\n          children !== undefined && [\"children are not rendered\", `${example} header={…} footer={…} />`],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // Wide in server HTML, where CSS hides the column on a phone until the client corrects it.\n  // The drawer exists only below the sm breakpoint; a screen that grows past it closes it.\n  const wide = useMediaQuery(\"(min-width: 640px)\", true);\n  const [open, setOpen] = useState(false);\n  // Focus goes back to the menu button when the sheet closes, in every browser.\n  const menuButton = useRef<HTMLButtonElement>(null);\n  if (wide && open) setOpen(false);\n\n  const [own, setOwn] = useState(defaultCollapsed);\n  const collapsed = collapsedProp ?? own;\n  const toggle = () => {\n    setOwn(!collapsed);\n    onCollapsedChange?.(!collapsed);\n  };\n\n  // An item's own `current` wins; otherwise the path decides, across nested links too.\n  const links = sections.flatMap((section) =>\n    section.items.flatMap((item): readonly (SidebarLinkItem | SidebarButtonItem)[] => (item.items !== undefined ? item.items : [item])),\n  );\n  const all = links.filter((item): item is SidebarLinkItem => item.href !== undefined);\n  const marked = all.some((item) => item.current)\n    ? undefined\n    : currentHref(\n        all.map((item) => item.href),\n        currentPath,\n      );\n  const isCurrent = (item: SidebarLinkItem | SidebarButtonItem) => item.href !== undefined && (Boolean(item.current) || item.href === marked);\n\n  // Which groups are open, by place; a group holding the current page starts open.\n  const [opened, setOpened] = useState<Readonly<Record<string, boolean>>>({});\n  const isOpen = (key: string, group: SidebarGroupItem) => opened[key] ?? group.items.some(isCurrent);\n\n  const id = useId();\n  /** One row's inside: icon (or the rail's letter), label and badge. */\n  const rowContent = (item: SidebarItem, rail: boolean) => (\n    <>\n      {(item.icon !== undefined || rail) && (\n        <span aria-hidden=\"true\" className={iconSlot}>\n          {item.icon !== undefined ? item.icon : item.label.charAt(0).toUpperCase()}\n        </span>\n      )}\n      <span className={rail ? \"sr-only\" : \"min-w-0 flex-1 truncate\"}>{item.label}</span>\n      {item.badge !== undefined && (\n        <>\n          {\" \"}\n          <span data-ouro-sidebar-badge=\"\" className={rail ? \"sr-only\" : badgeClass}>\n            {item.badge}\n          </span>\n        </>\n      )}\n    </>\n  );\n  /**\n   * A collapsed rail names each row with a tooltip, since only its icon shows.\n   *\n   * @claim \"A collapsed rail names each row\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar items > names each rail link with a tooltip on hover and keyboard focus)\n   * @claim \"A collapsed rail names each row\" registry/ouro/components/ouro/sidebar/sidebar.test.tsx verify:testExists(registry/ouro/components/ouro/sidebar/sidebar.test.tsx::Sidebar > collapses to a rail of icons with the toggle, keeping each link's name)\n   */\n  const tip = (rail: boolean, label: string, element: ReactElement) =>\n    rail ? (\n      <Tooltip content={label} side=\"right\">\n        {element}\n      </Tooltip>\n    ) : (\n      element\n    );\n  /** A link or a button row. */\n  const leaf = (item: SidebarLinkItem | SidebarButtonItem, rail: boolean, onNavigate: (() => void) | undefined) =>\n    tip(\n      rail,\n      item.label,\n      item.href !== undefined ? (\n        <RouterLink\n          href={item.href}\n          aria-current={isCurrent(item) ? \"page\" : undefined}\n          data-ouro-control=\"sidebar\"\n          data-ouro-part=\"link\"\n          onClick={(event) => {\n            onNavigate?.();\n            item.onClick?.(event);\n          }}\n          className={cn(row, rail && railRow)}\n        >\n          {rowContent(item, rail)}\n        </RouterLink>\n      ) : (\n        <button\n          type=\"button\"\n          data-ouro-control=\"sidebar\"\n          data-ouro-part=\"button\"\n          onClick={(event) => {\n            onNavigate?.();\n            item.onClick(event);\n          }}\n          className={cn(row, rail && railRow)}\n        >\n          {rowContent(item, rail)}\n        </button>\n      ),\n    );\n\n  /** The sections as lists: in the column (`rail` when collapsed) or in the drawer. */\n  const renderSections = (place: string, rail: boolean, onNavigate?: () => void) =>\n    sections.map((section, index) => (\n      // A rule above every section after the first, so a section's label reads as the start of a group.\n      <div key={index} className={cn(\"grid gap-1\", index > 0 && \"border-0 border-t border-solid border-border pt-4\")}>\n        {section.label !== undefined && (\n          <p id={`${id}${place}${index}`} className={rail ? \"sr-only\" : \"m-0 px-3 py-1 text-sm leading-5 font-semibold text-foreground\"}>\n            {section.label}\n          </p>\n        )}\n        <ul aria-labelledby={section.label !== undefined ? `${id}${place}${index}` : undefined} className={list}>\n          {section.items.map((item, position) => {\n            if (item.items === undefined) return <li key={position}>{leaf(item, rail, onNavigate)}</li>;\n            const holdsCurrent = item.items.some(isCurrent);\n            if (rail) {\n              // On the rail a group's links open in a menu beside its button, so they are in\n              // reach whether or not the sidebar can expand.\n              return (\n                <li key={position}>\n                  <Menu\n                    side=\"right\"\n                    closeLabel={closeLabel}\n                    trigger={\n                      <Tooltip content={item.label} side=\"right\">\n                        <button type=\"button\" data-current={holdsCurrent ? \"\" : undefined} data-ouro-control=\"sidebar\" data-ouro-part=\"group\" className={cn(row, \"data-current:text-foreground\", railRow)}>\n                          {rowContent(item, true)}\n                        </button>\n                      </Tooltip>\n                    }\n                  >\n                    {item.items.map((child, at) => (\n                      <MenuItem key={at} href={child.href} current={isCurrent(child)} onClick={child.onClick}>\n                        {child.label}\n                        {child.badge !== undefined && (\n                          <>\n                            {\" \"}\n                            <span className={cn(badgeClass, \"ms-2\")}>{child.badge}</span>\n                          </>\n                        )}\n                      </MenuItem>\n                    ))}\n                  </Menu>\n                </li>\n              );\n            }\n            const key = `${index}-${position}`;\n            const open = isOpen(key, item);\n            return (\n              <li key={position}>\n                <button\n                  type=\"button\"\n                  aria-expanded={open}\n                  aria-controls={`${id}${place}${key}`}\n                  data-ouro-control=\"sidebar\"\n                  data-ouro-part=\"group\"\n                  data-current={holdsCurrent && !open ? \"\" : undefined}\n                  onClick={() => setOpened({ ...opened, [key]: !open })}\n                  className={cn(row, \"data-current:text-foreground\")}\n                >\n                  {rowContent(item, false)}\n                  <svg\n                    aria-hidden=\"true\"\n                    viewBox=\"0 0 16 16\"\n                    fill=\"none\"\n                    stroke=\"currentColor\"\n                    strokeWidth=\"1.5\"\n                    strokeLinecap=\"round\"\n                    strokeLinejoin=\"round\"\n                    className={cn(\"size-4 shrink-0 rtl:-scale-x-100\", item.badge === undefined && \"ms-auto\", open && \"rotate-90 rtl:-rotate-90\")}\n                  >\n                    <path d=\"m6 4 4 4-4 4\" />\n                  </svg>\n                </button>\n                {open && (\n                  <ul id={`${id}${place}${key}`} className={cn(list, \"ms-5 mt-1 border-0 border-s border-solid border-border ps-2\")}>\n                    {item.items.map((child, at) => (\n                      <li key={at}>{leaf(child, false, onNavigate)}</li>\n                    ))}\n                  </ul>\n                )}\n              </li>\n            );\n          })}\n        </ul>\n      </div>\n    ));\n\n  return (\n    <div ref={ref} data-ouro=\"sidebar\" data-collapsed={collapsed ? \"\" : undefined} className={cn(\"max-sm:inline-flex sm:h-full\", className)}>\n      <Button\n        ref={menuButton}\n        data-ouro-sidebar-menu=\"\"\n        data-ouro-control=\"sidebar\"\n        data-ouro-part=\"menu\"\n        variant=\"plain\"\n        tone=\"secondary\"\n        aria-label={menuLabel}\n        // Only where the button shows: below the sm breakpoint it opens the sheet.\n        aria-haspopup={wide ? undefined : \"dialog\"}\n        aria-expanded={open}\n        onClick={() => setOpen(true)}\n        className=\"w-11 px-0 sm:hidden\"\n      >\n        <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" className=\"size-5\">\n          <path d=\"M3 5.5h14M3 10h14M3 14.5h14\" />\n        </svg>\n      </Button>\n      {wide && (\n        <nav aria-label={label} data-collapsed={collapsed ? \"\" : undefined} className={column}>\n          {header !== undefined && <div className=\"flex min-h-14 shrink-0 items-center overflow-hidden px-3 py-2\">{header}</div>}\n          <div data-ouro-sidebar-scroll=\"\" className=\"grid min-h-0 flex-1 content-start gap-6 overflow-y-auto overscroll-contain p-2\">\n            {renderSections(\"c\", collapsed)}\n          </div>\n          {collapsible && (\n            <div className=\"shrink-0 p-2\">\n              <button type=\"button\" aria-pressed={collapsed} data-ouro-control=\"sidebar\" data-ouro-part=\"collapse\" onClick={toggle} className={cn(row, collapsed && railRow)}>\n                <span aria-hidden=\"true\" className={iconSlot}>\n                  <svg viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"rtl:-scale-x-100\">\n                    <rect x=\"3\" y=\"4\" width=\"14\" height=\"12\" rx=\"2\" />\n                    <path d=\"M8 4v12\" />\n                  </svg>\n                </span>\n                <span className={collapsed ? \"sr-only\" : \"min-w-0 flex-1 truncate\"}>{collapseLabel}</span>\n              </button>\n            </div>\n          )}\n          {footer !== undefined && (\n            <div className=\"flex min-h-14 shrink-0 items-center overflow-hidden border-0 border-t border-solid border-border px-3 py-2\">{footer}</div>\n          )}\n        </nav>\n      )}\n      <SheetFrame title={menuLabel} hideTitle={header !== undefined} closeLabel={closeLabel} side=\"left\" open={open} onOpenChange={setOpen} finalFocus={menuButton}>\n        <div className=\"grid gap-4\">\n          {header !== undefined && <div className=\"flex min-h-11 items-center px-3\">{header}</div>}\n          <nav aria-label={label} className=\"grid gap-6\">\n            {renderSections(\"d\", false, () => setOpen(false))}\n          </nav>\n          {footer !== undefined && <div className=\"flex min-h-11 items-center border-0 border-t border-solid border-border px-3 pt-4\">{footer}</div>}\n        </div>\n      </SheetFrame>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/sidebar/sidebar.tsx"
    }
  ],
  "docs": "The column of links down the side of an app, in sections, with the current page marked `aria-current=\"page\"` and a bar at the start edge, distinct from hover and press highlights. Import: import { Sidebar } from \"@/components/ouro/sidebar/sidebar\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, kbd, menu, sheet, tooltip, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/sidebar.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}