{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-header",
  "type": "registry:ui",
  "title": "App Header",
  "description": "The bar at the top of an app-like view on a phone: a way back at the start, the view's title in the middle, one or two actions at the end. It sticks to the top, clears the notch or status bar (`env(safe-area-inset-top)`), and shows its surface and border…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "navigation",
    "pattern"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/app-header-edge.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/patterns/app-header.tsx",
      "target": "components/ui/patterns/app-header.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/app-header v1.1.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/app-header\n// What changed since: https://ds.interlace.tools/c/app-header#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — AppHeader, AppHeaderBack\n *\n * The bar at the top of an app-like view on a phone: a way back at the\n * start, the view's title in the middle, one or two actions at the end. It\n * sticks to the top, clears the notch or status bar\n * (`env(safe-area-inset-top)`), and shows its surface and border only once\n * content scrolls beneath it.\n *\n * ## Anatomy\n *\n *   <header data-slot=\"app-header\">                       (sticky)\n *     <div data-slot=\"app-header-bar\">\n *       <div data-slot=\"app-header-start\">{start}</div>\n *       <h1 data-slot=\"app-header-title\">{title}</h1>\n *       <div data-slot=\"app-header-end\">{end}</div>\n *     </div>\n *   </header>\n *   <div data-slot=\"app-header-large\">                    (largeTitle, scrolls away)\n *     <h1 data-slot=\"app-header-large-title\">{title}</h1>\n *   </div>\n *\n * ## Large title\n *\n * `largeTitle` sets the title big under the bar, the way a phone app opens a\n * top-level view. Once it scrolls up under the bar, the small title fades\n * into the bar (`data-collapsed`). The large title is the heading; the small\n * one is then hidden from assistive tech, so the title is read once.\n *\n * ## Motion\n *\n * The surface and border fade in (250ms, `--ease-move`); the small title\n * fades and rises 4px (150ms, `--ease-enter`). Reduced motion: both simply\n * change.\n *\n * ## MIN_VIEWPORT — 320\n *\n * The start and end columns share the room left by the title, which is cut\n * with an ellipsis in the bar (the large title wraps instead).\n *\n * | Rule | Concept                 | Where in this file                              |\n * | ---- | ----------------------- | ----------------------------------------------- |\n * | R4   | Extends native el       | `React.ComponentProps<'header'>`                |\n * | R6   | data-slot per part      | app-header, -bar, -start, -title, -end          |\n * | R7   | className merged + rest | `cn(BASE, className)` + `{...props}`            |\n * | R14  | Declares min viewport   | `data-min-viewport` + exported const            |\n * | R25  | Server component        | scroll state lives in `AppHeaderEdge`           |\n * | R26  | A11y from native el     | `<header>`, one heading, a named back link      |\n */\n\nimport { cn } from '@/lib/utils';\nimport { AppHeaderEdge } from '@/components/ui/patterns/app-header-edge';\n\nexport const MIN_VIEWPORT = 320 as const;\n\nexport interface AppHeaderProps extends Omit<React.ComponentProps<'header'>, 'title'> {\n  /** The view's name. */\n  title: React.ReactNode;\n  /** The start of the bar: usually `AppHeaderBack`, or a menu button. */\n  start?: React.ReactNode;\n  /** The end of the bar: one or two icon buttons. */\n  end?: React.ReactNode;\n  /** Set the title large under the bar, collapsing into the bar on scroll. @default false */\n  largeTitle?: boolean;\n  /**\n   * The element of the title. The view's main heading by default; pass `'p'` when the\n   * page already has its own h1. @default 'h1'\n   */\n  titleAs?: 'h1' | 'h2' | 'p';\n  /**\n   * When the bar shows its surface and border: `scroll` once content passes under it,\n   * `always` from the start. @default 'scroll'\n   */\n  edge?: 'scroll' | 'always';\n}\n\nfunction AppHeader({\n  title,\n  start,\n  end,\n  largeTitle = false,\n  titleAs: Title = 'h1',\n  edge = 'scroll',\n  className,\n  ...props\n}: AppHeaderProps) {\n  return (\n    <>\n      <header\n        data-slot=\"app-header\"\n        data-min-viewport={String(MIN_VIEWPORT)}\n        data-edge={edge}\n        className={cn(\n          'group/app-header sticky top-0 z-header border-b pt-[env(safe-area-inset-top,0px)]',\n          'px-[max(env(safe-area-inset-left,0px),env(safe-area-inset-right,0px))]',\n          'motion-safe:transition-[background-color,border-color] motion-safe:duration-(--duration-medium) motion-safe:ease-move',\n          edge === 'always'\n            ? 'border-border bg-background/90 supports-backdrop-filter:bg-background/75 backdrop-blur'\n            : 'data-scrolled:border-border data-scrolled:bg-background/90 supports-backdrop-filter:data-scrolled:bg-background/75 border-transparent data-scrolled:backdrop-blur',\n          className,\n        )}\n        {...props}\n      >\n        {edge === 'scroll' || largeTitle ? <AppHeaderEdge /> : null}\n        <div\n          data-slot=\"app-header-bar\"\n          className=\"mx-auto grid min-h-14 max-w-(--container-content) grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-2 px-2\"\n        >\n          <div data-slot=\"app-header-start\" className=\"flex min-w-0 items-center justify-start gap-1\">\n            {start}\n          </div>\n          {largeTitle ? (\n            <p\n              aria-hidden\n              data-slot=\"app-header-title\"\n              className={cn(\n                'max-w-[60vw] truncate text-center text-base font-semibold',\n                'translate-y-1 opacity-0 group-data-collapsed/app-header:translate-y-0 group-data-collapsed/app-header:opacity-100',\n                'motion-safe:transition-[opacity,translate] motion-safe:duration-(--duration-base) motion-safe:ease-enter',\n              )}\n            >\n              {title}\n            </p>\n          ) : (\n            <Title data-slot=\"app-header-title\" className=\"max-w-[60vw] truncate text-center text-base font-semibold\">\n              {title}\n            </Title>\n          )}\n          <div data-slot=\"app-header-end\" className=\"flex min-w-0 items-center justify-end gap-1\">\n            {end}\n          </div>\n        </div>\n      </header>\n      {largeTitle ? (\n        <div\n          data-slot=\"app-header-large\"\n          className=\"px-[max(env(safe-area-inset-left,0px),env(safe-area-inset-right,0px))]\"\n        >\n          <Title\n            data-slot=\"app-header-large-title\"\n            className=\"font-heading mx-auto max-w-(--container-content) px-4 pt-2 pb-3 text-3xl font-bold tracking-tight text-balance\"\n          >\n            {title}\n          </Title>\n        </div>\n      ) : null}\n    </>\n  );\n}\nAppHeader.displayName = 'AppHeader';\n\nexport interface AppHeaderBackLinkRenderProps {\n  href: string;\n  className: string;\n  children: React.ReactNode;\n  'aria-label'?: string;\n  'data-slot': 'app-header-back';\n}\n\nexport interface AppHeaderBackProps {\n  /** Where back goes: the parent view. */\n  href: string;\n  /** The word shown beside the arrow, such as the parent's name. @default 'Back' */\n  label?: string;\n  /** Show only the arrow, with the label as its accessible name. @default false */\n  iconOnly?: boolean;\n  /** Render-prop for a framework's router link. Spread the rest. */\n  renderLink?: (props: AppHeaderBackLinkRenderProps) => React.ReactElement;\n}\n\nconst defaultBackLink: NonNullable<AppHeaderBackProps['renderLink']> = ({ href, children, ...rest }) => (\n  <a href={href} {...rest}>\n    {children}\n  </a>\n);\n\n/** The start of an AppHeader: an arrow that points the reading direction's way back, and a word. */\nfunction AppHeaderBack({ href, label = 'Back', iconOnly = false, renderLink = defaultBackLink }: AppHeaderBackProps) {\n  return renderLink({\n    href,\n    'data-slot': 'app-header-back',\n    className: cn(\n      'text-primary hover:bg-muted -ms-1 inline-flex min-h-11 min-w-11 items-center gap-0.5 rounded-md pe-2 text-base font-medium',\n      'focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n      iconOnly && 'justify-center pe-0',\n    ),\n    ...(iconOnly ? { 'aria-label': label } : {}),\n    children: (\n      <>\n        <svg\n          aria-hidden\n          focusable=\"false\"\n          viewBox=\"0 0 24 24\"\n          fill=\"none\"\n          stroke=\"currentColor\"\n          strokeWidth={2}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n          className=\"size-6 shrink-0 rtl:-scale-x-100\"\n        >\n          <path d=\"m15 18-6-6 6-6\" />\n        </svg>\n        {iconOnly ? null : <span className=\"truncate\">{label}</span>}\n      </>\n    ),\n  });\n}\nAppHeaderBack.displayName = 'AppHeaderBack';\n\nexport { AppHeader, AppHeaderBack };\n"
    }
  ],
  "meta": {
    "tier": "pattern",
    "client": false,
    "minViewport": 320,
    "loading": false,
    "version": "1.1.0",
    "since": "2.0.0"
  },
  "docs": "## @interlace/app-header\n\nInstalled to `components/ui/patterns/app-header.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/patterns/app-header';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/app-header\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
