{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "site-header",
  "title": "Site Header",
  "description": "A sticky page header with brand, navigation, actions and a sheet menu for small screens, flagging data-scrolled once the page scrolls.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/button",
    "@corsair-ui/sheet",
    "@corsair-ui/use-in-view"
  ],
  "files": [
    {
      "path": "registry/default/ui/site-header.tsx",
      "content": "\"use client\";\n\nimport { MenuIcon } from \"lucide-react\";\nimport { useSyncExternalStore, type ComponentProps, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useInView } from \"@/registry/default/hooks/use-in-view\";\nimport { cn } from \"@/registry/default/lib/utils\";\nimport { Button } from \"@/registry/default/ui/button\";\nimport {\n  Sheet,\n  SheetClose,\n  SheetContent,\n  SheetDescription,\n  SheetHeader,\n  SheetTitle,\n  SheetTrigger,\n  type SheetSide,\n} from \"@/registry/default/ui/sheet\";\n\nconst subscribe = () => () => {};\n\n/** False while hydrating server HTML, true once running in the browser. */\nfunction useBrowser() {\n  return useSyncExternalStore(\n    subscribe,\n    () => true,\n    () => false\n  );\n}\n\ninterface SiteHeaderProps extends ComponentProps<\"header\"> {\n  /** Keeps the header at the top of the viewport while the page scrolls. */\n  sticky?: boolean;\n}\n\n/**\n * The bar across the top of a site: brand, main navigation, actions and a\n * menu button for small screens. It is a `<header>` (the banner landmark\n * when it is not inside another section). Sticky by default, on a\n * translucent background. Once the page has scrolled it sets\n * `data-scrolled=\"true\"`, so you can add a shadow or change the background\n * with `data-[scrolled=true]:…`; that comes from an IntersectionObserver\n * watching a 1px marker at the top of the page, not from a scroll listener.\n *\n * @example\n * <SiteHeader>\n *   <SiteHeaderContent>\n *     <SiteHeaderBrand>\n *       <a href=\"/\">Acme</a>\n *     </SiteHeaderBrand>\n *     <SiteHeaderNav>\n *       <NavLink href=\"/docs\" active>Docs</NavLink>\n *       <NavLink href=\"/blog\">Blog</NavLink>\n *     </SiteHeaderNav>\n *     <SiteHeaderActions>\n *       <Button size=\"sm\">Sign in</Button>\n *       <SiteHeaderMenu>\n *         <SiteHeaderMenuClose asChild>\n *           <NavLink href=\"/docs\">Docs</NavLink>\n *         </SiteHeaderMenuClose>\n *       </SiteHeaderMenu>\n *     </SiteHeaderActions>\n *   </SiteHeaderContent>\n * </SiteHeader>\n */\nfunction SiteHeader({ sticky = true, className, ...props }: SiteHeaderProps) {\n  const browser = useBrowser();\n  // Until the observer answers, assume the page is at the top.\n  const [observe, atTop] = useInView<HTMLDivElement>({ initial: true });\n  const supported = browser && typeof IntersectionObserver !== \"undefined\";\n\n  return (\n    <>\n      {supported\n        ? createPortal(\n            <div\n              ref={observe}\n              aria-hidden=\"true\"\n              data-slot=\"site-header-sentinel\"\n              className=\"pointer-events-none absolute top-0 left-0 h-px w-px\"\n            />,\n            document.body\n          )\n        : null}\n      <header\n        data-slot=\"site-header\"\n        data-sticky={sticky}\n        data-scrolled={supported && !atTop}\n        className={cn(\n          \"bg-background/80 w-full border-b backdrop-blur-[8px]\",\n          \"transition-[box-shadow,background-color] motion-reduce:transition-none\",\n          sticky && \"sticky top-0 z-40\",\n          className\n        )}\n        {...props}\n      />\n    </>\n  );\n}\n\n/** The centred row inside the header that lines the parts up. */\nfunction SiteHeaderContent({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"site-header-content\"\n      className={cn(\n        \"mx-auto flex h-14 w-full max-w-7xl items-center gap-4 px-4 sm:px-6\",\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\n/** Holds the logo link. Give the link a name: text, or an `aria-label` on an image logo. */\nfunction SiteHeaderBrand({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"site-header-brand\"\n      className={cn(\"flex shrink-0 items-center gap-2 font-semibold\", className)}\n      {...props}\n    />\n  );\n}\n\n/** The main navigation, a `<nav>` landmark named \"Main\". Hidden below `md`, where SiteHeaderMenu takes over. */\nfunction SiteHeaderNav({\n  className,\n  \"aria-label\": label = \"Main\",\n  ...props\n}: ComponentProps<\"nav\">) {\n  return (\n    <nav\n      data-slot=\"site-header-nav\"\n      aria-label={label}\n      className={cn(\"hidden items-center gap-1 md:flex\", className)}\n      {...props}\n    />\n  );\n}\n\n/** Buttons at the end of the header: sign in, theme toggle, the mobile menu. */\nfunction SiteHeaderActions({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"site-header-actions\"\n      className={cn(\"ml-auto flex items-center gap-2\", className)}\n      {...props}\n    />\n  );\n}\n\ninterface SiteHeaderMenuProps extends Omit<ComponentProps<typeof SheetContent>, \"title\"> {\n  /** Accessible name of the menu button. */\n  label?: string;\n  /** Title of the panel, which names it for screen readers. */\n  title?: ReactNode;\n  /** Classes for the title: `sr-only` hides it while keeping the name. */\n  titleClassName?: string;\n  /** Read out after the title when the panel opens. */\n  description?: ReactNode;\n  /** The edge the panel slides in from. */\n  side?: SheetSide;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  /** Classes for the menu button. */\n  triggerClassName?: string;\n}\n\n/**\n * The navigation for small screens: a menu button (hidden from `md` up)\n * that opens a Sheet with the children in it. The Sheet traps focus,\n * closes on Escape and returns focus to the button. Wrap each link in\n * SiteHeaderMenuClose with `asChild` so following it closes the panel.\n */\nfunction SiteHeaderMenu({\n  label = \"Open menu\",\n  title = \"Menu\",\n  titleClassName,\n  description,\n  side = \"right\",\n  open,\n  defaultOpen,\n  onOpenChange,\n  triggerClassName,\n  className,\n  children,\n  ...props\n}: SiteHeaderMenuProps) {\n  return (\n    <Sheet open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n      <SheetTrigger asChild>\n        <Button\n          variant=\"ghost\"\n          size=\"icon\"\n          aria-label={label}\n          data-slot=\"site-header-menu-trigger\"\n          className={cn(\"md:hidden\", triggerClassName)}\n        >\n          <MenuIcon aria-hidden=\"true\" />\n        </Button>\n      </SheetTrigger>\n      <SheetContent\n        side={side}\n        data-slot=\"site-header-menu\"\n        className={className}\n        // Radix warns about a missing description unless it is opted out of.\n        {...(description ? null : { \"aria-describedby\": undefined })}\n        {...props}\n      >\n        <SheetHeader>\n          <SheetTitle className={titleClassName}>{title}</SheetTitle>\n          {description ? <SheetDescription>{description}</SheetDescription> : null}\n        </SheetHeader>\n        <div\n          data-slot=\"site-header-menu-body\"\n          className=\"flex flex-col gap-1 overflow-y-auto px-4 pb-4\"\n        >\n          {children}\n        </div>\n      </SheetContent>\n    </Sheet>\n  );\n}\n\n/** Closes the mobile menu. Use `asChild` around a link so following it closes the panel. */\nconst SiteHeaderMenuClose = SheetClose;\n\nexport {\n  SiteHeader,\n  SiteHeaderActions,\n  SiteHeaderBrand,\n  SiteHeaderContent,\n  SiteHeaderMenu,\n  SiteHeaderMenuClose,\n  SiteHeaderNav,\n  type SiteHeaderMenuProps,\n  type SiteHeaderProps,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}