{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "navbar",
  "type": "registry:ui",
  "title": "Navbar",
  "description": "A responsive site header: a brand, a row of links and a slot for actions. Below `md` the links move into a menu button that opens them in a sheet.",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "lucide-react",
    "radix-ui"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/button",
    "@rivier-ui/cn",
    "@rivier-ui/sheet"
  ],
  "files": [
    {
      "path": "registry/ui/navbar.tsx",
      "type": "registry:ui",
      "target": "components/ui/navbar.tsx",
      "content": "\"use client\";\n/**\n * @name navbar\n * @category ui\n * @description A responsive site header: a brand, a row of links and a slot for actions. Below `md` the links move into a menu button that opens them in a sheet.\n * @when The top of a site or app with up to about seven top-level links. The links are written once, as NavbarLink children, and shown in the bar or in the sheet. The sheet closes when a link in it is followed, and focus returns to the menu button. Mark the current page with `current`. With a router link, pass it through `asChild`. For navigation inside a page use tabs; for the path to a page use breadcrumb.\n * @example\n * <Navbar\n *   brand={<a href=\"/\" className=\"text-base font-medium\">Rivier</a>}\n *   actions={<Button size=\"sm\" asChild><a href=\"/contact\">Contact</a></Button>}\n * >\n *   <NavbarLink href=\"/work\" current>Work</NavbarLink>\n *   <NavbarLink href=\"/studio\">Studio</NavbarLink>\n *   <NavbarLink href=\"/about\">About</NavbarLink>\n * </Navbar>\n */\nimport { Slot } from \"radix-ui\";\nimport { Menu } from \"lucide-react\";\nimport { useEffect, useState, type ComponentProps, type MouseEvent, type ReactNode } from \"react\";\nimport { buttonVariants } from \"@/components/ui/button\";\nimport { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger, type SheetSide } from \"@/components/ui/sheet\";\nimport { cn } from \"@/lib/cn\";\n\nexport type NavbarProps = Omit<ComponentProps<\"header\">, \"children\"> & {\n  /** The logo or name, usually a link to the home page. */\n  brand?: ReactNode;\n  /** Buttons at the end of the bar. They stay in the bar on phones, so keep them few and short. */\n  actions?: ReactNode;\n  /** The links: NavbarLink elements. Rendered in the bar from `md`, and in the sheet below it. */\n  children?: ReactNode;\n  /** Accessible name of the navigation. */\n  label?: string;\n  /** The title shown at the top of the menu sheet. */\n  menuTitle?: string;\n  /** Accessible name of the menu button. */\n  menuLabel?: string;\n  /** The edge the menu sheet opens from. \"bottom\" is within reach of the thumb on phones. */\n  menuSide?: SheetSide;\n};\n\nexport function Navbar({ className, brand, actions, children, label = \"Main\", menuTitle = \"Menu\", menuLabel = \"Open menu\", menuSide = \"bottom\", ...props }: NavbarProps) {\n  const [open, setOpen] = useState(false);\n\n  // The menu button disappears at `md`: close the sheet if the window grows past it while open.\n  useEffect(() => {\n    if (!open) return;\n    const wide = window.matchMedia(\"(min-width: 48rem)\");\n    const close = (): void => {\n      if (wide.matches) setOpen(false);\n    };\n    close();\n    wide.addEventListener(\"change\", close);\n    return () => wide.removeEventListener(\"change\", close);\n  }, [open]);\n\n  // Following a link closes the sheet; Radix then returns focus to the menu button.\n  const closeOnNavigation = (event: MouseEvent<HTMLElement>): void => {\n    if (event.target instanceof Element && event.target.closest(\"a[href]\")) setOpen(false);\n  };\n\n  return (\n    <header data-slot=\"navbar\" className={cn(\"w-full border-b bg-background text-foreground\", className)} {...props}>\n      <div className=\"mx-auto flex h-14 w-full max-w-page items-center gap-2 px-4 md:gap-6 md:px-6\">\n        {brand ? (\n          <div data-slot=\"navbar-brand\" className=\"flex min-w-0 shrink-0 items-center\">\n            {brand}\n          </div>\n        ) : null}\n        <nav data-slot=\"navbar-links\" aria-label={label} className=\"hidden min-w-0 items-center gap-1 md:flex\">\n          {children}\n        </nav>\n        <div data-slot=\"navbar-actions\" className=\"ms-auto flex items-center gap-2\">\n          {actions}\n        </div>\n        <Sheet open={open} onOpenChange={setOpen}>\n          <SheetTrigger data-slot=\"navbar-menu-button\" aria-label={menuLabel} className={cn(buttonVariants({ variant: \"ghost\", size: \"icon\" }), \"md:hidden\")}>\n            <Menu aria-hidden=\"true\" strokeWidth={1.5} />\n          </SheetTrigger>\n          <SheetContent side={menuSide} aria-describedby={undefined}>\n            <SheetHeader>\n              <SheetTitle>{menuTitle}</SheetTitle>\n            </SheetHeader>\n            <nav data-slot=\"navbar-menu\" aria-label={label} onClick={closeOnNavigation} className=\"flex flex-col gap-1 px-3 pb-5\">\n              {children}\n            </nav>\n          </SheetContent>\n        </Sheet>\n      </div>\n    </header>\n  );\n}\n\nexport type NavbarLinkProps = ComponentProps<\"a\"> & {\n  /** The page being shown: emphasised, and marked `aria-current=\"page\"`. */\n  current?: boolean;\n  /** Render the child element (a router link, for example) with the link's look. */\n  asChild?: boolean;\n};\n\n/** A link in the bar; a full-width row, 44px tall, when it is in the menu sheet. */\nexport function NavbarLink({ className, current = false, asChild = false, ...props }: NavbarLinkProps) {\n  const Comp = asChild ? Slot.Root : \"a\";\n  return (\n    <Comp\n      data-slot=\"navbar-link\"\n      aria-current={current ? \"page\" : undefined}\n      className={cn(\n        \"inline-flex h-control shrink-0 items-center rounded-control px-3 text-sm font-medium whitespace-nowrap text-muted-foreground transition-[background-color,color] duration-instant ease-out hover:bg-accent hover:text-foreground aria-[current=page]:text-foreground motion-reduce:transition-none in-data-[slot=navbar-menu]:h-control-lg in-data-[slot=navbar-menu]:w-full in-data-[slot=navbar-menu]:text-base\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "The top of a site or app with up to about seven top-level links. The links are written once, as NavbarLink children, and shown in the bar or in the sheet. The sheet closes when a link in it is followed, and focus returns to the menu button. Mark the current page with `current`. With a router link, pass it through `asChild`. For navigation inside a page use tabs; for the path to a page use breadcrumb.",
    "example": "<Navbar\n  brand={<a href=\"/\" className=\"text-base font-medium\">Rivier</a>}\n  actions={<Button size=\"sm\" asChild><a href=\"/contact\">Contact</a></Button>}\n>\n  <NavbarLink href=\"/work\" current>Work</NavbarLink>\n  <NavbarLink href=\"/studio\">Studio</NavbarLink>\n  <NavbarLink href=\"/about\">About</NavbarLink>\n</Navbar>",
    "client": true
  }
}
