{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "page-header",
  "type": "registry:ui",
  "title": "Page Header",
  "description": "Title, description, and main actions of a page.",
  "categories": [
    "layout"
  ],
  "dependencies": [
    "@base-ui/react@1.9.0",
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/button.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/page-header.tsx",
      "type": "registry:ui",
      "target": "components/ui/page-header.tsx",
      "content": "'use client';\n\nimport { createContext, useContext, useEffect, type ReactElement, type ReactNode, type Ref } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useRender } from '@base-ui/react/use-render';\nimport { ChevronLeftIcon } from '@/lib/sprout/icons/chevron-left-icon';\nimport { ChevronRightIcon } from '@/lib/sprout/icons/chevron-right-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { Button } from '@/components/ui/button';\n\nexport interface PageChrome {\n  title: HTMLElement | null;\n  actions: HTMLElement | null;\n  documentTitle?: ((title: string) => string) | undefined;\n}\n\nexport const PageChromeContext = createContext<PageChrome>({\n  title: null,\n  actions: null,\n});\n\nexport interface PageLink {\n  label: string;\n  link: ReactElement;\n}\n\nexport interface PageHeaderProps {\n  title: ReactNode;\n  description?: ReactNode;\n  actions?: ReactNode;\n  back?: PageLink | undefined;\n  parent?: PageLink | undefined;\n  titleId?: string | undefined;\n  titleRef?: Ref<HTMLHeadingElement> | undefined;\n  focusable?: boolean | undefined;\n  className?: string | undefined;\n}\n\nfunction ParentLink({ link, label }: PageLink) {\n  return useRender({\n    defaultTagName: 'a',\n    render: link,\n    props: {\n      'data-slot': 'page-breadcrumb-link',\n      className: 'sprout-page-header-breadcrumb-link',\n      children: label,\n    },\n  });\n}\n\nexport function PageHeader({\n  title,\n  description,\n  actions,\n  back,\n  parent,\n  titleId,\n  titleRef,\n  focusable,\n  className,\n}: PageHeaderProps) {\n  const chrome = useContext(PageChromeContext);\n  const format = chrome.documentTitle;\n  const text = typeof title === 'string' ? title : null;\n  useEffect(() => {\n    if (!text || !format) return;\n    const previous = document.title;\n    document.title = format(text);\n    return () => {\n      document.title = previous;\n    };\n  }, [text, format]);\n\n  const inChrome = !!(chrome.title && chrome.actions);\n  const placement = inChrome ? 'chrome' : 'page';\n  const heading = (\n    <h1\n      id={titleId}\n      ref={titleRef}\n      tabIndex={focusable ? -1 : undefined}\n      data-slot=\"page-title\"\n      data-placement={placement}\n      className=\"sprout-page-header-title\"\n    >\n      {title}\n    </h1>\n  );\n  const trail = parent && (\n    <nav\n      aria-label=\"Breadcrumb\"\n      data-slot=\"page-breadcrumb\"\n      data-placement={placement}\n      className=\"sprout-page-header-breadcrumb\"\n    >\n      <ol className=\"sprout-page-header-breadcrumb-list\">\n        <li className=\"sprout-page-header-breadcrumb-item\">\n          <ParentLink {...parent} />\n        </li>\n        <li role=\"presentation\" aria-hidden=\"true\" className=\"sprout-page-header-breadcrumb-separator\">\n          <ChevronRightIcon size=\"sm\" />\n        </li>\n        <li aria-current=\"page\" className=\"sprout-page-header-breadcrumb-item sprout-page-header-breadcrumb-current\">\n          {heading}\n        </li>\n      </ol>\n    </nav>\n  );\n  const backButton = back && (\n    <Button\n      variant=\"ghost\"\n      size=\"sm\"\n      nativeButton={false}\n      render={back.link}\n      data-slot=\"page-back\"\n      className=\"sprout-page-header-back\"\n    >\n      <ChevronLeftIcon data-icon=\"inline-start\" aria-hidden=\"true\" />\n      <span className=\"sprout-page-header-back-label\">{back.label}</span>\n    </Button>\n  );\n\n  if (inChrome) {\n    return (\n      <>\n        {createPortal(\n          <>\n            {backButton}\n            {trail ?? heading}\n          </>,\n          chrome.title!,\n        )}\n        {actions &&\n          createPortal(\n            <div data-slot=\"page-actions\" data-placement=\"chrome\" className=\"sprout-page-header-actions\">\n              {actions}\n            </div>,\n            chrome.actions!,\n          )}\n        {description && (\n          <p data-slot=\"page-description\" className={cn('sprout-page-header-description', className)}>\n            {description}\n          </p>\n        )}\n      </>\n    );\n  }\n  return (\n    <header data-slot=\"page-header\" className={cn('sprout-page-header', className)}>\n      {backButton}\n      <div className=\"sprout-page-header-row\">\n        <div className=\"sprout-page-header-text\">\n          {trail ?? heading}\n          {description && (\n            <p data-slot=\"page-description\" className=\"sprout-page-header-description\">\n              {description}\n            </p>\n          )}\n        </div>\n        {actions && (\n          <div data-slot=\"page-actions\" data-placement=\"page\" className=\"sprout-page-header-actions\">\n            {actions}\n          </div>\n        )}\n      </div>\n    </header>\n  );\n}\n\nexport interface PageActionsProps {\n  children: ReactNode;\n  className?: string | undefined;\n}\n\nexport function PageActions({ children, className }: PageActionsProps) {\n  const { actions } = useContext(PageChromeContext);\n  return actions ? (\n    createPortal(\n      <div data-slot=\"page-actions\" data-placement=\"chrome\" className={cn('sprout-page-header-actions', className)}>\n        {children}\n      </div>,\n      actions,\n    )\n  ) : (\n    <div data-slot=\"page-actions\" data-placement=\"inline\" className={cn('sprout-page-header-actions', className)}>\n      {children}\n    </div>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/chevron-left-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/chevron-left-icon.tsx",
      "content": "import { ArrowLeft01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const ChevronLeftIcon = /* @__PURE__ */ createIcon(glyph, 'ChevronLeftIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/chevron-right-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/chevron-right-icon.tsx",
      "content": "import { ArrowRight01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const ChevronRightIcon = /* @__PURE__ */ createIcon(glyph, 'ChevronRightIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-page-header": {
        "min-width": "0",
        "font-family": "var(--sprout-font)",
        "color": "var(--sprout-text)",
        "gap": ".75rem",
        "display": "grid"
      },
      ".sprout-page-header > .sprout-page-header-back": {
        "justify-self": "start"
      },
      ".sprout-page-header-row": {
        "flex-wrap": "wrap",
        "justify-content": "space-between",
        "align-items": "flex-start",
        "gap": "1rem",
        "display": "flex"
      },
      ".sprout-page-header-text": {
        "flex": "20rem",
        "gap": ".25rem",
        "min-width": "0",
        "display": "grid"
      },
      ".sprout-page-header-title": {
        "color": "var(--sprout-text)",
        "letter-spacing": "normal",
        "margin": "0",
        "font-weight": "500"
      },
      ".sprout-page-header-title[data-placement=\"page\"]": {
        "overflow-wrap": "break-word",
        "font-size": "1.5rem",
        "line-height": "2rem"
      },
      ".sprout-page-header-title[data-placement=\"chrome\"]": {
        "min-width": "0",
        "font-size": "var(--sprout-text-sm)",
        "text-overflow": "ellipsis",
        "white-space": "nowrap",
        "line-height": "1.25rem",
        "overflow": "hidden"
      },
      ".sprout-page-header-title:focus:not(:focus-visible)": {
        "outline": "none"
      },
      ".sprout-page-header-title:focus-visible": {
        "outline": "var(--sprout-focus-width) solid var(--sprout-focus-ring)",
        "outline-offset": "0",
        "border-radius": "2px"
      },
      ".sprout-page-header-description": {
        "color": "var(--sprout-muted)",
        "font-family": "var(--sprout-font)",
        "font-size": "var(--sprout-text-sm)",
        "overflow-wrap": "break-word",
        "margin": "0",
        "line-height": "1.25rem"
      },
      ".sprout-page-header-actions": {
        "align-items": "center",
        "gap": ".5rem",
        "display": "flex"
      },
      ".sprout-page-header-actions[data-placement=\"page\"]": {
        "flex-wrap": "wrap"
      },
      ".sprout-page-header-actions[data-placement=\"inline\"]": {
        "justify-content": "flex-end"
      },
      ".sprout-page-header-breadcrumb": {
        "min-width": "0"
      },
      ".sprout-page-header-breadcrumb-list": {
        "min-width": "0",
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-sm)",
        "flex-wrap": "nowrap",
        "align-items": "center",
        "gap": "6px",
        "margin": "0",
        "padding": "0",
        "line-height": "1.25rem",
        "list-style": "none",
        "display": "flex"
      },
      ".sprout-page-header-breadcrumb-item": {
        "flex-shrink": "0",
        "align-items": "center",
        "gap": "4px",
        "display": "inline-flex"
      },
      ".sprout-page-header-breadcrumb-current": {
        "flex-shrink": "1",
        "min-width": "0"
      },
      ".sprout-page-header-breadcrumb-link": {
        "color": "inherit",
        "white-space": "nowrap",
        "border-radius": "2px",
        "text-decoration": "none"
      },
      "@media (hover: hover) and (pointer: fine)": {
        ".sprout-page-header-breadcrumb-link:hover": {
          "color": "var(--sprout-text)"
        }
      },
      ".sprout-page-header-breadcrumb-link:focus-visible": {
        "outline": "var(--sprout-focus-width) solid var(--sprout-focus-ring)",
        "outline-offset": "0"
      },
      ".sprout-page-header-breadcrumb[data-placement=\"chrome\"] .sprout-page-header-breadcrumb-item:first-child": {
        "flex-shrink": "3",
        "min-width": "2rem"
      },
      ".sprout-page-header-breadcrumb[data-placement=\"chrome\"] .sprout-page-header-breadcrumb-link": {
        "text-overflow": "ellipsis",
        "min-width": "0",
        "overflow": "hidden"
      },
      ".sprout-page-header-breadcrumb[data-placement=\"chrome\"] .sprout-page-header-breadcrumb-current": {
        "min-width": "2.5rem"
      },
      ".sprout-page-header-breadcrumb-separator": {
        "flex-shrink": "0",
        "display": "inline-flex"
      },
      ".sprout-page-header-breadcrumb-separator > svg": {
        "width": "14px",
        "height": "14px"
      },
      "@media (width <= 639px)": {
        ".sprout-page-header-back": {
          "width": "calc(var(--sprout-control-height) - 4px)",
          "padding-inline": "0"
        },
        ".sprout-page-header-back-label": {
          "clip-path": "inset(50%)",
          "white-space": "nowrap",
          "border": "0",
          "width": "1px",
          "height": "1px",
          "margin": "-1px",
          "padding": "0",
          "position": "absolute",
          "overflow": "hidden"
        }
      },
      "@media (prefers-reduced-motion: no-preference)": {
        ".sprout-page-header-breadcrumb-link": {
          "transition": "color var(--sprout-motion-fast) ease-out"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/page-header/",
  "meta": {
    "source": "packages/sprout/src/components/page-header.tsx"
  }
}
