{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "site-header",
  "title": "Site Header",
  "description": "A marketing site's top navigation with a skip link and a drawer on phones: a plain row of links, panels of grouped links, or pieces floating over the page.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/button.json",
    "https://miseui.junsu4621.workers.dev/r/drawer.json",
    "https://miseui.junsu4621.workers.dev/r/floating-nav.json",
    "https://miseui.junsu4621.workers.dev/r/navigation-menu.json"
  ],
  "files": [
    {
      "path": "registry/miseui/blocks/site-header.tsx",
      "content": "import type * as React from \"react\"\r\nimport { useId, useState } from \"react\"\r\nimport { cn } from \"@/registry/miseui/lib/utils\"\r\nimport { HeaderBar } from \"./site-header-bar\"\r\nimport { HeaderFloating } from \"./site-header-floating\"\r\nimport { HeaderMega } from \"./site-header-mega\"\r\nimport { SkipLink, type HeaderContent, type SiteHeaderPosition } from \"./site-header-parts\"\r\nimport { SAMPLE_LINKS, SAMPLE_MENU_LINKS, SAMPLE_MENUS, type SiteHeaderAction, type SiteHeaderLink, type SiteHeaderMenu } from \"./site-header-sample\"\r\n\r\ntype SiteHeaderVariant = \"bar\" | \"mega\" | \"floating\"\r\n\r\nconst DEFAULT_PRIMARY: SiteHeaderAction = { label: \"Get started\", href: \"#get-started\" }\r\nconst DEFAULT_SECONDARY: SiteHeaderAction = { label: \"Log in\", href: \"#log-in\" }\r\n\r\ninterface SiteHeaderProps extends React.ComponentProps<\"div\"> {\r\n  /** `bar` a plain row of links, `mega` panels of grouped links, `floating` pieces over the page. All become a drawer on phones. Anything else is `bar`. */\r\n  variant?: SiteHeaderVariant\r\n  brandName?: React.ReactNode\r\n  brandHref?: string\r\n  /** The links in the row. On `mega` they sit after the menus. */\r\n  links?: readonly SiteHeaderLink[]\r\n  /** `mega` and its drawer only. */\r\n  menus?: readonly SiteHeaderMenu[]\r\n  /** Null removes it. */\r\n  primaryAction?: SiteHeaderAction | null\r\n  /** Null removes it. */\r\n  secondaryAction?: SiteHeaderAction | null\r\n  /** The href of the current page, usually from your router. Left out, the last link pressed is marked. */\r\n  currentHref?: string\r\n  defaultCurrentHref?: string\r\n  onNavigate?: (href: string) => void\r\n  /** `sticky` stays inside this block, which is what you want in a frame or a preview. `fixed` attaches to the window. */\r\n  position?: SiteHeaderPosition\r\n  navLabel?: string\r\n  skipLabel?: string\r\n  /** The id of your main element, when it is not inside this block. Children get a main with this id. */\r\n  mainId?: string\r\n  /** The page. It is wrapped in a main, the target of the skip link. */\r\n  children?: React.ReactNode\r\n}\r\n\r\nconst MAIN_CLASS: Record<SiteHeaderVariant, Record<SiteHeaderPosition, string>> = {\r\n  bar: { sticky: \"\", fixed: \"pt-14\" },\r\n  mega: { sticky: \"\", fixed: \"pt-14\" },\r\n  // Nothing holds the row's height, so the page starts clear of it unless the owner wants to run underneath.\r\n  floating: { sticky: \"pt-16\", fixed: \"pt-16\" },\r\n}\r\n\r\nfunction chooseView(variant: string | undefined): SiteHeaderVariant {\r\n  return variant === \"mega\" || variant === \"floating\" ? variant : \"bar\"\r\n}\r\n\r\nfunction SiteHeader({ variant, brandName = \"Paperline\", brandHref = \"#top\", links, menus = SAMPLE_MENUS, primaryAction = DEFAULT_PRIMARY, secondaryAction = DEFAULT_SECONDARY, currentHref, defaultCurrentHref, onNavigate, position = \"sticky\", navLabel = \"Main\", skipLabel = \"Skip to content\", mainId, className, children, ...props }: SiteHeaderProps) {\r\n  const generatedId = useId()\r\n  const targetId = mainId ?? generatedId\r\n  const [lastPressed, setLastPressed] = useState(defaultCurrentHref)\r\n  const view = chooseView(variant)\r\n  const content: HeaderContent = {\r\n    brandName,\r\n    brandHref,\r\n    links: links ?? (view === \"mega\" ? SAMPLE_MENU_LINKS : SAMPLE_LINKS),\r\n    menus: view === \"mega\" ? menus : [],\r\n    primaryAction,\r\n    secondaryAction,\r\n    current: currentHref ?? lastPressed,\r\n    onSelect: (href) => {\r\n      setLastPressed(href)\r\n      onNavigate?.(href)\r\n    },\r\n    navLabel,\r\n    position,\r\n  }\r\n  const hasPage = children !== undefined && children !== null\r\n  return (\r\n    <div data-slot=\"site-header\" data-variant={view} data-position={position} className={cn(\"@container relative isolate w-full bg-background\", className)} {...props}>\r\n      {/* Only when there is something to skip to. */}\r\n      {hasPage || mainId ? <SkipLink targetId={targetId} label={skipLabel} /> : null}\r\n      {view === \"bar\" ? <HeaderBar content={content} /> : null}\r\n      {view === \"mega\" ? <HeaderMega content={content} /> : null}\r\n      {view === \"floating\" ? <HeaderFloating content={content} /> : null}\r\n      {hasPage ? (\r\n        <main id={targetId} tabIndex={-1} data-slot=\"site-header-main\" className={cn(\"outline-none\", MAIN_CLASS[view][position])}>\r\n          {children}\r\n        </main>\r\n      ) : null}\r\n    </div>\r\n  )\r\n}\r\n\r\nexport { SiteHeader, type SiteHeaderAction, type SiteHeaderLink, type SiteHeaderMenu, type SiteHeaderPosition, type SiteHeaderProps, type SiteHeaderVariant }\r\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/site-header-bar.tsx",
      "content": "import { cn } from \"@/registry/miseui/lib/utils\"\nimport { GLASS_CLASS } from \"@/registry/miseui/ui/floating-nav-views\"\nimport { HeaderAction, HeaderBrand, HeaderDrawer, positionClass, type HeaderContent } from \"./site-header-parts\"\n\nconst LINK_CLASS = \"inline-flex h-9 items-center rounded-md px-3 text-[13px] font-medium whitespace-nowrap outline-none transition-colors duration-(--duration-fast) ease-(--ease-mise) focus-visible:ring-[3px] focus-visible:ring-ring/50 pointer-coarse:h-10\"\n\n/** A plain row, for a site with a handful of pages. Every link stays one press away, and nothing opens over the page. */\nfunction HeaderBar({ content }: { content: HeaderContent }) {\n  const { brandName, brandHref, links, primaryAction, secondaryAction, current, onSelect, navLabel, position } = content\n  return (\n    <header data-slot=\"site-header-bar\" className={cn(\"z-40 border-b\", GLASS_CLASS, positionClass(position))}>\n      <div className=\"mx-auto flex h-14 max-w-6xl items-center gap-4 px-4 @3xl:gap-6 @3xl:px-6\">\n        <HeaderBrand name={brandName} href={brandHref} />\n        <nav aria-label={navLabel} className=\"hidden min-w-0 @3xl:block\">\n          <ul className=\"flex items-center gap-1\">\n            {links.map((link) => (\n              <li key={link.href}>\n                <a\n                  href={link.href}\n                  aria-current={current === link.href ? \"page\" : undefined}\n                  onClick={() => onSelect(link.href)}\n                  className={cn(LINK_CLASS, current === link.href ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\")}\n                >\n                  {link.label}\n                </a>\n              </li>\n            ))}\n          </ul>\n        </nav>\n        <div className=\"ms-auto flex items-center gap-2\">\n          {secondaryAction ? <HeaderAction action={secondaryAction} variant=\"ghost\" className=\"hidden @3xl:inline-flex\" /> : null}\n          {primaryAction ? <HeaderAction action={primaryAction} variant=\"mise\" /> : null}\n          <HeaderDrawer content={content} className=\"-me-2 @3xl:hidden\" />\n        </div>\n      </div>\n    </header>\n  )\n}\n\nexport { HeaderBar }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/site-header-floating.tsx",
      "content": "import { cn } from \"@/registry/miseui/lib/utils\"\r\nimport { FloatingNav } from \"@/registry/miseui/ui/floating-nav\"\r\nimport { GLASS_CLASS } from \"@/registry/miseui/ui/floating-nav-views\"\r\nimport { HeaderAction, HeaderBrand, HeaderDrawer, positionClass, type HeaderContent } from \"./site-header-parts\"\r\n\r\nconst CHIP_CLASS = \"pointer-events-auto rounded-full shadow-md ring-1 shadow-black/5 ring-foreground/10 dark:shadow-black/40\"\r\n\r\n/**\r\n * Pieces on the page instead of a bar across it, for a site whose first screen is a picture worth keeping whole.\r\n * The row has no height of its own, so the page runs under it, and it sticks inside the block rather than the window.\r\n * The accent is the active link's highlight, so the action stays in ink.\r\n */\r\nfunction HeaderFloating({ content }: { content: HeaderContent }) {\r\n  const { brandName, brandHref, links, primaryAction, secondaryAction, current, onSelect, navLabel, position } = content\r\n  const items = links.map((link) => ({ value: link.href, label: link.label, href: link.href }))\r\n  return (\r\n    <header data-slot=\"site-header-floating\" className={cn(\"pointer-events-none z-40 h-0\", positionClass(position))}>\r\n      <div className=\"relative mx-auto flex max-w-6xl items-start justify-between gap-2 px-3 pt-3 @3xl:px-4\">\r\n        <HeaderBrand name={brandName} href={brandHref} className={cn(\"px-4 pointer-coarse:min-h-12\", CHIP_CLASS, GLASS_CLASS)} />\r\n        {/* Above any page, in the middle of the row. On a phone the drawer takes over, so the pill does not have to scroll. */}\r\n        <FloatingNav label={navLabel} variant=\"pill\" position=\"absolute\" items={items} value={current ?? \"\"} onValueChange={onSelect} className=\"top-3 hidden @3xl:flex\" />\r\n        <div className={cn(\"flex items-center gap-1 p-1 @3xl:gap-2\", CHIP_CLASS, GLASS_CLASS)}>\r\n          {secondaryAction ? <HeaderAction action={secondaryAction} variant=\"ghost\" className=\"hidden h-8 rounded-full @5xl:inline-flex\" /> : null}\r\n          {primaryAction ? <HeaderAction action={primaryAction} variant=\"default\" className=\"h-8 rounded-full\" /> : null}\r\n          <HeaderDrawer content={content} className=\"-my-1 rounded-full @3xl:hidden\" />\r\n        </div>\r\n      </div>\r\n    </header>\r\n  )\r\n}\r\n\r\nexport { HeaderFloating }\r\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/site-header-mega.tsx",
      "content": "import { cn } from \"@/registry/miseui/lib/utils\"\nimport { GLASS_CLASS } from \"@/registry/miseui/ui/floating-nav-views\"\nimport {\n  NavigationMenu,\n  NavigationMenuContent,\n  NavigationMenuGroup,\n  NavigationMenuItem,\n  NavigationMenuLink,\n  NavigationMenuList,\n  NavigationMenuPanelLink,\n  NavigationMenuTrigger,\n} from \"@/registry/miseui/ui/navigation-menu\"\nimport { HeaderAction, HeaderBrand, HeaderDrawer, positionClass, type HeaderContent } from \"./site-header-parts\"\n\n/** The positioner spans the whole row, so a panel shares the header's width and keeps its own margin from the edge. */\nconst PANEL_ROOM_CLASS = \"[&_[data-slot=navigation-menu-positioner]]:px-2 @3xl:[&_[data-slot=navigation-menu-positioner]]:px-4\"\n\nfunction MegaMenus({ content }: { content: HeaderContent }) {\n  const { menus, links, current, onSelect } = content\n  return (\n    <NavigationMenuList className=\"hidden flex-nowrap @3xl:flex\">\n      {menus.map((menu) => (\n        <NavigationMenuItem key={menu.label} value={menu.label}>\n          <NavigationMenuTrigger>{menu.label}</NavigationMenuTrigger>\n          <NavigationMenuContent>\n            {menu.groups.map((group) => (\n              <NavigationMenuGroup key={group.title} title={group.title}>\n                {group.links.map((link) => (\n                  <NavigationMenuPanelLink key={link.href} href={link.href} title={link.label} description={link.description} active={current === link.href} onClick={() => onSelect(link.href)} />\n                ))}\n              </NavigationMenuGroup>\n            ))}\n          </NavigationMenuContent>\n        </NavigationMenuItem>\n      ))}\n      {links.map((link) => (\n        <NavigationMenuItem key={link.href}>\n          <NavigationMenuLink href={link.href} active={current === link.href} onClick={() => onSelect(link.href)}>\n            {link.label}\n          </NavigationMenuLink>\n        </NavigationMenuItem>\n      ))}\n    </NavigationMenuList>\n  )\n}\n\n/** For a product with more pages than a row can hold. The panels name where each link goes, so nobody has to open a page to find out. */\nfunction HeaderMega({ content }: { content: HeaderContent }) {\n  const { brandName, brandHref, primaryAction, secondaryAction, navLabel, position } = content\n  return (\n    <header data-slot=\"site-header-mega\" className={cn(\"z-40 border-b\", GLASS_CLASS, positionClass(position))}>\n      <NavigationMenu variant=\"mega\" effect=\"materialize\" aria-label={navLabel} className={cn(\"mx-auto flex h-14 max-w-6xl items-center gap-4 px-4 @3xl:gap-6 @3xl:px-6\", PANEL_ROOM_CLASS)}>\n        <HeaderBrand name={brandName} href={brandHref} />\n        <MegaMenus content={content} />\n        <div className=\"ms-auto flex items-center gap-2\">\n          {secondaryAction ? <HeaderAction action={secondaryAction} variant=\"ghost\" className=\"hidden @3xl:inline-flex\" /> : null}\n          {primaryAction ? <HeaderAction action={primaryAction} variant=\"mise\" /> : null}\n          <HeaderDrawer content={content} className=\"-me-2 @3xl:hidden\" />\n        </div>\n      </NavigationMenu>\n    </header>\n  )\n}\n\nexport { HeaderMega }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/site-header-parts.tsx",
      "content": "import type * as React from \"react\"\nimport { useState } from \"react\"\nimport { Menu } from \"lucide-react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Button } from \"@/registry/miseui/ui/button\"\nimport { Drawer, DrawerBody, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from \"@/registry/miseui/ui/drawer\"\nimport type { SiteHeaderAction, SiteHeaderLink, SiteHeaderMenu } from \"./site-header-sample\"\n\n/** Sticks or stays fixed inside the block by default, so a frame around it contains the header. */\ntype SiteHeaderPosition = \"sticky\" | \"fixed\"\n\ninterface HeaderContent {\n  brandName: React.ReactNode\n  brandHref: string\n  links: readonly SiteHeaderLink[]\n  menus: readonly SiteHeaderMenu[]\n  primaryAction: SiteHeaderAction | null\n  secondaryAction: SiteHeaderAction | null\n  current: string | undefined\n  onSelect: (href: string) => void\n  navLabel: string\n  position: SiteHeaderPosition\n}\n\nfunction HeaderBrand({ name, href, className }: { name: React.ReactNode; href: string; className?: string }) {\n  return (\n    <a href={href} className={cn(\"inline-flex min-h-10 shrink-0 items-center rounded-md text-[15px] font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\", className)}>\n      {name}\n    </a>\n  )\n}\n\nfunction HeaderAction({ action, variant, className }: { action: SiteHeaderAction; variant: React.ComponentProps<typeof Button>[\"variant\"]; className?: string }) {\n  return (\n    <Button asChild variant={variant} className={cn(\"pointer-coarse:h-10\", className)}>\n      <a href={action.href}>{action.label}</a>\n    </Button>\n  )\n}\n\nconst DRAWER_LINK_CLASS = \"flex min-h-11 items-center rounded-md px-3 text-[15px] outline-none transition-colors duration-(--duration-fast) ease-(--ease-mise) hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset aria-[current=page]:bg-accent aria-[current=page]:font-medium\"\n\nfunction DrawerLink({ link, current, onPress }: { link: SiteHeaderLink; current: string | undefined; onPress: (href: string) => void }) {\n  return (\n    <li>\n      <a href={link.href} aria-current={current === link.href ? \"page\" : undefined} onClick={() => onPress(link.href)} className={DRAWER_LINK_CLASS}>\n        {link.label}\n      </a>\n    </li>\n  )\n}\n\n/** Everything the header hides on a phone, all open at once: tapping through folds to find one link costs more than a short scroll. */\nfunction HeaderDrawer({ content, className }: { content: HeaderContent; className?: string }) {\n  const [open, setOpen] = useState(false)\n  const { brandName, links, menus, primaryAction, secondaryAction, current, onSelect, navLabel } = content\n  const press = (href: string) => {\n    onSelect(href)\n    setOpen(false)\n  }\n  return (\n    <Drawer open={open} onOpenChange={setOpen} side=\"right\">\n      <DrawerTrigger asChild>\n        <Button variant=\"ghost\" size=\"icon\" aria-label=\"Open menu\" className={cn(\"size-10\", className)}>\n          <Menu aria-hidden=\"true\" />\n        </Button>\n      </DrawerTrigger>\n      <DrawerContent aria-describedby={undefined}>\n        <DrawerHeader>\n          <DrawerTitle>{brandName}</DrawerTitle>\n        </DrawerHeader>\n        <DrawerBody>\n          <nav aria-label={navLabel} className=\"flex flex-col gap-4\">\n            {menus.flatMap((menu) => menu.groups).map((group) => (\n              <div key={group.title} className=\"flex flex-col gap-1\">\n                <p className=\"px-3 text-[13px] text-muted-foreground\">{group.title}</p>\n                <ul>\n                  {group.links.map((link) => (\n                    <DrawerLink key={link.href} link={link} current={current} onPress={press} />\n                  ))}\n                </ul>\n              </div>\n            ))}\n            {links.length > 0 ? (\n              <ul>\n                {links.map((link) => (\n                  <DrawerLink key={link.href} link={link} current={current} onPress={press} />\n                ))}\n              </ul>\n            ) : null}\n          </nav>\n        </DrawerBody>\n        {primaryAction || secondaryAction ? (\n          <DrawerFooter className=\"flex-col sm:flex-col\">\n            {primaryAction ? <HeaderAction action={primaryAction} variant=\"mise\" className=\"w-full\" /> : null}\n            {secondaryAction ? <HeaderAction action={secondaryAction} variant=\"outline\" className=\"w-full\" /> : null}\n          </DrawerFooter>\n        ) : null}\n      </DrawerContent>\n    </Drawer>\n  )\n}\n\n/** A hash link would fight a hash router, and Safari does not move focus for it anyway. */\nfunction SkipLink({ targetId, label }: { targetId: string; label: string }) {\n  return (\n    <a\n      data-slot=\"site-header-skip\"\n      href={`#${targetId}`}\n      onClick={(event) => {\n        event.preventDefault()\n        const target = document.getElementById(targetId)\n        if (target && !target.hasAttribute(\"tabindex\")) target.setAttribute(\"tabindex\", \"-1\")\n        target?.focus()\n      }}\n      className=\"sr-only focus:not-sr-only focus:absolute focus:start-2 focus:top-2 focus:z-50 focus:inline-flex focus:h-10 focus:items-center focus:rounded-md focus:bg-background focus:px-3 focus:text-sm focus:shadow-md focus:ring-[3px] focus:ring-ring/50 focus:outline-none\"\n    >\n      {label}\n    </a>\n  )\n}\n\nfunction positionClass(position: SiteHeaderPosition) {\n  return position === \"fixed\" ? \"fixed inset-x-0 top-0\" : \"sticky top-0\"\n}\n\nexport { HeaderAction, HeaderBrand, HeaderDrawer, positionClass, SkipLink, type HeaderContent, type SiteHeaderPosition }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/site-header-sample.ts",
      "content": "interface SiteHeaderLink {\n  label: string\n  href: string\n  /** One line saying where it goes, shown in `mega` panels. */\n  description?: string\n}\n\ninterface SiteHeaderGroup {\n  title: string\n  links: readonly SiteHeaderLink[]\n}\n\ninterface SiteHeaderMenu {\n  label: string\n  groups: readonly SiteHeaderGroup[]\n}\n\ninterface SiteHeaderAction {\n  label: string\n  href: string\n}\n\nconst SAMPLE_LINKS: readonly SiteHeaderLink[] = [\n  { label: \"Features\", href: \"#features\" },\n  { label: \"Pricing\", href: \"#pricing\" },\n  { label: \"Docs\", href: \"#docs\" },\n  { label: \"Changelog\", href: \"#changelog\" },\n]\n\nconst SAMPLE_MENU_LINKS: readonly SiteHeaderLink[] = [{ label: \"Pricing\", href: \"#pricing\" }]\n\nconst SAMPLE_MENUS: readonly SiteHeaderMenu[] = [\n  {\n    label: \"Product\",\n    groups: [\n      {\n        title: \"Invoicing\",\n        links: [\n          { label: \"Invoices\", href: \"#invoices\", description: \"Send, track and resend.\" },\n          { label: \"Reminders\", href: \"#reminders\", description: \"Follow up without writing it.\" },\n        ],\n      },\n      {\n        title: \"Getting paid\",\n        links: [\n          { label: \"Payment links\", href: \"#links\", description: \"A page anyone can pay on.\" },\n          { label: \"Bank transfers\", href: \"#transfers\", description: \"Matched to the right invoice.\" },\n        ],\n      },\n      {\n        title: \"Books\",\n        links: [\n          { label: \"Reports\", href: \"#reports\", description: \"What came in, by month.\" },\n          { label: \"Exports\", href: \"#exports\", description: \"Files your accountant can open.\" },\n        ],\n      },\n    ],\n  },\n  {\n    label: \"Resources\",\n    groups: [\n      {\n        title: \"Learn\",\n        links: [\n          { label: \"Guides\", href: \"#guides\", description: \"From first invoice to year end.\" },\n          { label: \"API docs\", href: \"#docs\", description: \"For building it into your tools.\" },\n        ],\n      },\n      {\n        title: \"Stay current\",\n        links: [\n          { label: \"Changelog\", href: \"#changelog\", description: \"What shipped this month.\" },\n          { label: \"Status\", href: \"#status\", description: \"Whether everything is up.\" },\n        ],\n      },\n    ],\n  },\n]\n\nexport { SAMPLE_LINKS, SAMPLE_MENUS, SAMPLE_MENU_LINKS, type SiteHeaderAction, type SiteHeaderGroup, type SiteHeaderLink, type SiteHeaderMenu }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}