{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"page-header","type":"registry:block","title":"Page header","description":"The top of every app page: breadcrumbs, title, status, actions and tabs. As you scroll, the title glides up and shrinks into a sticky bar.","author":"Hairline UI","dependencies":["lucide-react"],"registryDependencies":["https://hairlineui.com/r/dropdown-menu.json?as=dependency","https://hairlineui.com/r/number-roll.json?as=dependency","https://hairlineui.com/r/status-button.json?as=dependency","https://hairlineui.com/r/text-morph.json?as=dependency"],"files":[{"path":"registry/page-header.tsx","type":"registry:component","content":"// Hairline UI · page-header · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronLeft, Ellipsis } from \"lucide-react\";\nimport { DropdownMenu } from \"./dropdown-menu\";\nimport { NumberRoll } from \"./number-roll\";\nimport { StatusButton, type ActionStatus } from \"./status-button\";\nimport { TextMorph } from \"./text-morph\";\nimport { EASE_OUT } from \"./ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * PAGE HEADER: where you are, what this is, what you can do\n *\n *   condense  scroll and the large title glides up and shrinks\n *             into a sticky bar, in step with the scroll (not a\n *             toggle). The trail scrolls away and the parent page\n *             becomes a back link, the actions ride into the bar,\n *             the tabs stay pinned under it\n *   trail     going deeper, the crumbs you share stay and the new\n *             one slides in from the right; going up, the crumbs\n *             you leave slide out the same way. The title morphs\n *   actions   async buttons that say what happened in place;\n *             narrow, the secondary ones fold into a menu\n *   tabs      the underline is thrown to the new tab, counts roll\n *\n * Layout follows the header's own width, not the screen's.\n * ───────────────────────────────────────────────────────── */\n\nexport interface PageCrumb {\n  label: string;\n  href?: string;\n  onClick?: () => void;\n}\n\nexport interface PageAction {\n  id: string;\n  label: string;\n  icon?: React.ReactNode;\n  /** The main action of the page: filled, and kept out of the narrow menu. */\n  primary?: boolean;\n  destructive?: boolean;\n  /** Run the action. Return a promise and the button shows pending, then done or failed. */\n  onAction?: () => unknown | Promise<unknown>;\n  /** Labels while it runs, after it works, and after it fails. */\n  pendingLabel?: string;\n  successLabel?: string;\n  errorLabel?: string;\n}\n\nexport interface PageTab {\n  id: string;\n  label: string;\n  count?: number;\n  href?: string;\n}\n\nexport interface PageHeaderProps {\n  title: string;\n  description?: string;\n  /** The trail to this page, without the page itself. The last crumb is the parent. */\n  breadcrumbs?: PageCrumb[];\n  /** Beside the title: a status badge, a visibility pill. */\n  badge?: React.ReactNode;\n  /** A line under the description: owners, dates, counts. */\n  meta?: React.ReactNode;\n  actions?: PageAction[];\n  tabs?: PageTab[];\n  tab?: string;\n  defaultTab?: string;\n  onTabChange?: (id: string) => void;\n  /** Shrink into a sticky bar on scroll. */\n  condense?: boolean;\n  /** The element that scrolls. Defaults to the nearest scrolling ancestor, or the window. */\n  scrollContainer?: React.RefObject<HTMLElement | null>;\n  /** The link component for crumbs and tabs with href, e.g. Next.js Link. */\n  linkAs?: React.ElementType;\n  className?: string;\n}\n\nconst BAR = 52;\nconst NO_CRUMBS: PageCrumb[] = [];\nconst NO_ACTIONS: PageAction[] = [];\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () => React.useSyncExternalStore(subscribeReduced, () => window.matchMedia(reducedQuery).matches, () => false);\n\nconst clamp01 = (n: number) => Math.min(1, Math.max(0, n));\nconst smooth = (a: number, b: number, x: number) => {\n  const t = clamp01((x - a) / (b - a));\n  return t * t * (3 - 2 * t);\n};\nconst keyOf = (c: PageCrumb) => c.href ?? c.label;\n\n/** The nearest ancestor that scrolls vertically, or null for the window. */\nfunction scrollParent(el: HTMLElement | null): HTMLElement | null {\n  for (let node = el?.parentElement; node; node = node.parentElement) {\n    const y = getComputedStyle(node).overflowY;\n    if ((y === \"auto\" || y === \"scroll\" || y === \"overlay\") && node.scrollHeight > node.clientHeight) return node;\n  }\n  return null;\n}\n\n/** offsetTop of el inside ancestor, summed through offset parents (transforms don't count). */\nfunction offsetIn(el: HTMLElement, ancestor: HTMLElement) {\n  let top = 0;\n  let left = 0;\n  for (let node: HTMLElement | null = el; node && node !== ancestor; node = node.offsetParent as HTMLElement | null) {\n    top += node.offsetTop;\n    left += node.offsetLeft;\n  }\n  return { top, left };\n}\n\n/* ── the trail ────────────────────────────────────────────── */\n\ntype TrailEntry = { crumb: PageCrumb; key: string; out: boolean; fresh: boolean };\n\nfunction Slash() {\n  return (\n    <svg viewBox=\"0 0 16 16\" aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-muted-foreground/60\">\n      <path d=\"M10 3.5 6 12.5\" stroke=\"currentColor\" strokeWidth=\"1.3\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction Trail({ items, linkAs: LinkAs, reduced }: { items: PageCrumb[]; linkAs: React.ElementType; reduced: boolean }) {\n  // Crumbs both trails share stay put; the rest leave or arrive, so moving between pages reads as going deeper or up.\n  const [prev, setPrev] = React.useState(items);\n  const [gen, setGen] = React.useState(0);\n  const [entries, setEntries] = React.useState<TrailEntry[]>(() => items.map((crumb) => ({ crumb, key: keyOf(crumb), out: false, fresh: false })));\n  if (prev !== items) {\n    setPrev(items);\n    setGen(gen + 1);\n    let shared = 0;\n    while (shared < items.length && shared < prev.length && keyOf(items[shared]) === keyOf(prev[shared])) shared++;\n    const stay = entries.filter((e) => !e.out).slice(0, shared).map((e, i) => ({ ...e, crumb: items[i], fresh: false }));\n    const leaving = entries.filter((e) => !e.out).slice(shared).map((e) => ({ ...e, out: true }));\n    const arriving = items.slice(shared).map((crumb, i) => ({ crumb, key: `${keyOf(crumb)}#${gen + 1}-${i}`, out: false, fresh: !reduced }));\n    setEntries(reduced ? [...stay, ...arriving] : [...stay, ...leaving, ...arriving]);\n  }\n  const hasLeaving = entries.some((e) => e.out);\n  React.useEffect(() => {\n    if (!hasLeaving) return;\n    const timer = window.setTimeout(() => setEntries((list) => list.filter((e) => !e.out)), 380);\n    return () => window.clearTimeout(timer);\n  }, [hasLeaving]);\n\n  let arrivingIndex = 0;\n  return (\n    <ol className=\"flex min-w-0 items-center text-[13px] text-muted-foreground\">\n      {entries.map((entry) => {\n        const { crumb } = entry;\n        const delay = entry.fresh ? 60 + arrivingIndex++ * 70 : 0;\n        const inner = crumb.href ? (\n          <LinkAs href={crumb.href} onClick={crumb.onClick} className=\"cursor-pointer rounded-[6px] px-1 py-0.5 transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\">\n            {crumb.label}\n          </LinkAs>\n        ) : crumb.onClick ? (\n          <button type=\"button\" onClick={crumb.onClick} className=\"cursor-pointer rounded-[6px] px-1 py-0.5 transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\">\n            {crumb.label}\n          </button>\n        ) : (\n          <span className=\"px-1 py-0.5\">{crumb.label}</span>\n        );\n        return (\n          <li\n            key={entry.key}\n            aria-hidden={entry.out || undefined}\n            inert={entry.out}\n            className=\"grid min-w-0 transition-[grid-template-columns,opacity,translate,filter] duration-[360ms] ease-[cubic-bezier(0.16,1,0.3,1)]\"\n            style={{\n              gridTemplateColumns: entry.out ? \"0fr\" : \"1fr\",\n              opacity: entry.out ? 0 : 1,\n              translate: entry.out ? \"10px 0\" : \"0 0\",\n              filter: entry.out ? \"blur(3px)\" : \"none\",\n              animation: entry.fresh ? `ui-slide-from-right 380ms cubic-bezier(0.16,1,0.3,1) ${delay}ms backwards` : undefined,\n            }}\n          >\n            <span className=\"flex min-w-0 items-center overflow-clip whitespace-nowrap\">\n              {inner}\n              <Slash />\n            </span>\n          </li>\n        );\n      })}\n    </ol>\n  );\n}\n\n/* ── tabs ─────────────────────────────────────────────────── */\n\nfunction TabStrip({\n  tabs,\n  value,\n  onChange,\n  linkAs: LinkAs,\n  reduced,\n}: {\n  tabs: PageTab[];\n  value: string;\n  onChange: (id: string) => void;\n  linkAs: React.ElementType;\n  reduced: boolean;\n}) {\n  const list = React.useRef<HTMLDivElement>(null);\n  const line = React.useRef<HTMLSpanElement>(null);\n  const placed = React.useRef(false);\n  const [edges, setEdges] = React.useState({ left: false, right: false });\n\n  // The underline is thrown to the new tab, measured from layout so it survives font loading and resizes.\n  React.useLayoutEffect(() => {\n    const el = list.current;\n    const bar = line.current;\n    if (!el || !bar) return;\n    const place = () => {\n      const tab = el.querySelector<HTMLElement>(`[data-tab=\"${CSS.escape(value)}\"]`);\n      if (!tab) return;\n      bar.style.transition = placed.current && !reduced ? `transform 420ms cubic-bezier(0.34,1.36,0.64,1), width 360ms ${EASE_OUT}` : \"none\";\n      bar.style.width = `${tab.offsetWidth - 16}px`;\n      bar.style.transform = `translateX(${tab.offsetLeft + 8}px)`;\n      placed.current = true;\n    };\n    place();\n    // Keep the chosen tab in view on narrow widths, scrolling the strip only (never the page).\n    const tab = el.querySelector<HTMLElement>(`[data-tab=\"${CSS.escape(value)}\"]`);\n    if (tab && (tab.offsetLeft < el.scrollLeft || tab.offsetLeft + tab.offsetWidth > el.scrollLeft + el.clientWidth)) {\n      el.scrollTo({ left: tab.offsetLeft - 24, behavior: reduced ? \"auto\" : \"smooth\" });\n    }\n    const observer = new ResizeObserver(place);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [value, reduced, tabs]);\n\n  const onScroll = (e: React.UIEvent<HTMLDivElement>) => {\n    const el = e.currentTarget;\n    const left = el.scrollLeft > 2;\n    const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 2;\n    setEdges((s) => (s.left === left && s.right === right ? s : { left, right }));\n  };\n  React.useEffect(() => {\n    const el = list.current;\n    if (!el) return;\n    const observer = new ResizeObserver(() => {\n      const left = el.scrollLeft > 2;\n      const right = el.scrollLeft + el.clientWidth < el.scrollWidth - 2;\n      setEdges((s) => (s.left === left && s.right === right ? s : { left, right }));\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  const onKey = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (![\"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\"].includes(e.key)) return;\n    const items = [...(list.current?.querySelectorAll<HTMLElement>(\"[data-tab]\") ?? [])];\n    const i = items.indexOf(document.activeElement as HTMLElement);\n    if (i < 0) return;\n    e.preventDefault();\n    const next = e.key === \"Home\" ? 0 : e.key === \"End\" ? items.length - 1 : Math.min(items.length - 1, Math.max(0, i + (e.key === \"ArrowRight\" ? 1 : -1)));\n    items[next]?.focus();\n  };\n\n  return (\n    <div className=\"relative border-b border-border\">\n      <div\n        ref={list}\n        role=\"navigation\"\n        aria-label=\"Page sections\"\n        onScroll={onScroll}\n        onKeyDown={onKey}\n        className=\"relative flex overflow-x-auto px-4 [scrollbar-width:none] @min-[36rem]:px-5 [&::-webkit-scrollbar]:hidden\"\n        style={{\n          maskImage: `linear-gradient(to right, ${edges.left ? \"transparent\" : \"black\"}, black 24px, black calc(100% - 24px), ${edges.right ? \"transparent\" : \"black\"})`,\n        }}\n      >\n        {tabs.map((t) => {\n          const active = t.id === value;\n          const cls = `relative flex h-10 shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-[8px] px-2.5 text-[13.5px] outline-none transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50 ${\n            active ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\"\n          }`;\n          const body = (\n            <>\n              {t.label}\n              {t.count !== undefined && (\n                <span className={`flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-[5px] text-[11px] tabular-nums transition-colors duration-200 ${active ? \"bg-accent text-foreground\" : \"bg-[color-mix(in_oklab,var(--foreground)_6%,transparent)] text-muted-foreground\"}`}>\n                  <NumberRoll value={t.count} duration={700} />\n                </span>\n              )}\n            </>\n          );\n          return t.href ? (\n            <LinkAs key={t.id} href={t.href} data-tab={t.id} aria-current={active ? \"page\" : undefined} onClick={() => onChange(t.id)} className={cls}>\n              {body}\n            </LinkAs>\n          ) : (\n            <button key={t.id} type=\"button\" data-tab={t.id} aria-current={active ? \"page\" : undefined} onClick={() => onChange(t.id)} className={cls}>\n              {body}\n            </button>\n          );\n        })}\n        <span ref={line} aria-hidden=\"true\" className=\"pointer-events-none absolute bottom-0 left-0 h-[2px] rounded-full bg-foreground\" style={{ width: 0 }} />\n      </div>\n    </div>\n  );\n}\n\n/* ── the header ───────────────────────────────────────────── */\n\nexport function PageHeader({\n  title,\n  description,\n  breadcrumbs = NO_CRUMBS,\n  badge,\n  meta,\n  actions = NO_ACTIONS,\n  tabs,\n  tab: tabProp,\n  defaultTab,\n  onTabChange,\n  condense = true,\n  scrollContainer,\n  linkAs: LinkAs = \"a\",\n  className = \"\",\n}: PageHeaderProps) {\n  const reduced = useReducedMotion();\n  const [ownTab, setOwnTab] = React.useState(defaultTab ?? tabs?.[0]?.id ?? \"\");\n  const tab = tabProp ?? ownTab;\n  const [status, setStatus] = React.useState<Record<string, ActionStatus>>({});\n  // A new set of actions (another page) starts idle, so a \"Created\" from before never greets you on the way back.\n  const actionKey = actions.map((a) => a.id).join(\"|\");\n  const [lastActions, setLastActions] = React.useState(actionKey);\n  if (lastActions !== actionKey) {\n    setLastActions(actionKey);\n    setStatus({});\n  }\n\n  const header = React.useRef<HTMLElement>(null);\n  const sentinel = React.useRef<HTMLDivElement>(null);\n  const titleRef = React.useRef<HTMLHeadingElement>(null);\n  const badgeRef = React.useRef<HTMLSpanElement>(null);\n  const actionsRef = React.useRef<HTMLDivElement>(null);\n  const descRef = React.useRef<HTMLParagraphElement>(null);\n  const metaRef = React.useRef<HTMLDivElement>(null);\n  const trailRef = React.useRef<HTMLDivElement>(null);\n  const backRef = React.useRef<HTMLDivElement>(null);\n  const barTitleRef = React.useRef<HTMLSpanElement>(null);\n  const ruleRef = React.useRef<HTMLSpanElement>(null);\n\n  const parent = breadcrumbs[breadcrumbs.length - 1];\n  const primary = actions.filter((a) => a.primary);\n  const secondary = actions.filter((a) => !a.primary);\n\n  const run = async (action: PageAction) => {\n    if (!action.onAction || status[action.id] === \"pending\") return;\n    const result = action.onAction();\n    if (!(result instanceof Promise)) return;\n    setStatus((s) => ({ ...s, [action.id]: \"pending\" }));\n    try {\n      await result;\n      setStatus((s) => ({ ...s, [action.id]: \"success\" }));\n    } catch {\n      setStatus((s) => ({ ...s, [action.id]: \"error\" }));\n    }\n  };\n  const reset = (id: string) => setStatus((s) => ({ ...s, [id]: \"idle\" }));\n\n  /* the condense: geometry once per resize, transforms once per scrolled frame */\n  React.useLayoutEffect(() => {\n    const el = header.current;\n    if (!el || !condense) return;\n    const scroller = scrollContainer?.current ?? scrollParent(el);\n    const target: HTMLElement | Window = scroller ?? window;\n    const geo = { travel: 0, titleDy: 0, titleDx: 0, scale: 1, badgeDx: 0, badgeDy: 0, badgeTravels: true, swap: false, actionsDy: 0 };\n    let frame = 0;\n\n    const measure = () => {\n      const t = titleRef.current;\n      if (!t) return;\n      const tabsHeight = (el.querySelector<HTMLElement>(\"[data-tabs]\")?.offsetHeight ?? 0);\n      geo.travel = Math.max(0, el.offsetHeight - BAR - tabsHeight);\n      el.style.top = geo.travel > 20 ? `${-geo.travel}px` : \"0px\";\n      const bar = geo.travel + BAR / 2;\n      const tPos = offsetIn(t, el);\n      const size = parseFloat(getComputedStyle(t).fontSize) || 26;\n      geo.scale = 15 / size;\n      geo.titleDy = bar - (tPos.top + t.offsetHeight / 2);\n      const back = backRef.current;\n      geo.titleDx = parent && back ? back.offsetWidth + 2 : 0;\n      const a = actionsRef.current;\n      const aPos = a ? offsetIn(a, el) : null;\n      if (a && aPos) geo.actionsDy = bar - (aPos.top + a.offsetHeight / 2);\n      if (back) back.style.top = `${bar - back.offsetHeight / 2}px`;\n\n      // What fits in the bar: from the back link to the actions.\n      const barLeft = tPos.left + geo.titleDx;\n      const room = (aPos ? aPos.left - 12 : el.clientWidth - tPos.left) - barLeft;\n      const oneLine = t.offsetHeight < size * 1.6;\n      const scaledWidth = t.offsetWidth * geo.scale;\n      const b = badgeRef.current;\n      const badgeWidth = b ? b.offsetWidth + 10 : 0;\n      // A one-line title that fits glides into the bar as itself; a wrapped or long one hands over to a one-line copy.\n      geo.swap = !oneLine || scaledWidth > room;\n      geo.badgeTravels = !!b && !geo.swap && scaledWidth + badgeWidth <= room;\n      if (b) {\n        const bPos = offsetIn(b, el);\n        geo.badgeDx = barLeft + scaledWidth + 10 - bPos.left;\n        geo.badgeDy = bar - (bPos.top + b.offsetHeight / 2);\n      }\n      const copy = barTitleRef.current;\n      if (copy) {\n        copy.style.left = `${barLeft}px`;\n        copy.style.maxWidth = `${Math.max(0, room)}px`;\n        copy.style.top = `${bar - copy.offsetHeight / 2}px`;\n      }\n      apply();\n    };\n\n    const apply = () => {\n      frame = 0;\n      const s = sentinel.current;\n      if (!s || geo.travel <= 20) return;\n      const top = scroller ? scroller.getBoundingClientRect().top : 0;\n      const t = clamp01((top - s.getBoundingClientRect().top) / geo.travel);\n      const titleEl = titleRef.current;\n      if (titleEl) {\n        titleEl.style.transform = t ? `translate3d(${geo.titleDx * t}px,${geo.titleDy * t}px,0) scale(${1 + (geo.scale - 1) * t})` : \"\";\n        titleEl.style.opacity = geo.swap ? String(1 - smooth(0.7, 0.95, t)) : \"\";\n      }\n      const copy = barTitleRef.current;\n      if (copy) {\n        copy.style.opacity = geo.swap ? String(smooth(0.75, 1, t)) : \"0\";\n        copy.style.transform = `translate3d(0,${-(1 - t) * geo.titleDy}px,0)`;\n      }\n      const badgeEl = badgeRef.current;\n      if (badgeEl) {\n        badgeEl.style.transform = t && geo.badgeTravels ? `translate3d(${geo.badgeDx * t}px,${geo.badgeDy * t}px,0)` : \"\";\n        badgeEl.style.opacity = geo.badgeTravels ? \"\" : String(1 - smooth(0, 0.35, t));\n      }\n      if (actionsRef.current) actionsRef.current.style.transform = t ? `translate3d(0,${geo.actionsDy * t}px,0)` : \"\";\n      // Gone before the title passes over them.\n      const fade = String(1 - smooth(0, 0.3, t));\n      if (descRef.current) descRef.current.style.opacity = fade;\n      if (metaRef.current) metaRef.current.style.opacity = fade;\n      if (trailRef.current) trailRef.current.style.opacity = String(1 - smooth(0, 0.4, t));\n      const back = backRef.current;\n      if (back) {\n        // Rides with the title, so the chevron and the name arrive in the bar together.\n        const shown = smooth(0.7, 1, t);\n        back.style.opacity = String(shown);\n        back.style.transform = `translate3d(${(1 - shown) * -6}px,${-(1 - t) * geo.titleDy}px,0)`;\n        back.inert = shown < 0.5;\n      }\n      if (ruleRef.current) ruleRef.current.style.opacity = String(smooth(0.85, 1, t));\n    };\n    const onScroll = () => {\n      if (!frame) frame = requestAnimationFrame(apply);\n    };\n\n    const observer = new ResizeObserver(measure);\n    observer.observe(el);\n    target.addEventListener(\"scroll\", onScroll, { passive: true });\n    return () => {\n      observer.disconnect();\n      target.removeEventListener(\"scroll\", onScroll);\n      if (frame) cancelAnimationFrame(frame);\n      frame = 0;\n    };\n  }, [condense, scrollContainer, parent, title, badge, description, meta, tabs, actions]);\n\n  const actionButton = (a: PageAction) => (\n    <StatusButton\n      key={a.id}\n      variant={a.primary ? \"primary\" : \"outline\"}\n      status={status[a.id] ?? \"idle\"}\n      icon={a.icon}\n      labels={{ idle: a.label, pending: a.pendingLabel ?? a.label, success: a.successLabel ?? \"Done\", error: a.errorLabel ?? \"Try again\" }}\n      onClick={() => run(a)}\n      onReset={() => reset(a.id)}\n      className={a.primary ? \"\" : \"@max-[36rem]:hidden\"}\n    />\n  );\n\n  return (\n    <>\n      <div ref={sentinel} aria-hidden=\"true\" />\n      <header ref={header} className={`@container sticky top-0 z-20 bg-background ${className}`}>\n        {/* The parent page as a back link: on narrow widths always, in the condensed bar always. */}\n        {parent && (\n          <div ref={backRef} className=\"absolute left-3 z-[1] opacity-0 @min-[36rem]:left-4\" inert style={{ top: BAR / 2 - 16 }}>\n            <BackLink crumb={parent} linkAs={LinkAs} compact />\n          </div>\n        )}\n        {condense && (\n          <span ref={barTitleRef} aria-hidden=\"true\" className=\"pointer-events-none absolute left-0 top-0 z-[1] truncate whitespace-nowrap text-[15px] font-semibold leading-[1.2] tracking-[-0.02em] text-foreground opacity-0\">\n            {title}\n          </span>\n        )}\n        <div className=\"relative px-4 pb-4 pt-4 @min-[36rem]:px-6 @min-[36rem]:pt-5\">\n          {breadcrumbs.length > 0 && (\n            <div ref={trailRef} className=\"mb-2 flex h-6 min-w-0 items-center\">\n              <nav aria-label=\"Breadcrumb\" className=\"-ml-1 hidden min-w-0 @min-[36rem]:block\">\n                <Trail items={breadcrumbs} linkAs={LinkAs} reduced={reduced} />\n              </nav>\n              {parent && (\n                <div className=\"-ml-1.5 min-w-0 max-w-[45%] @min-[36rem]:hidden\">\n                  <BackLink crumb={parent} linkAs={LinkAs} />\n                </div>\n              )}\n            </div>\n          )}\n          <div className=\"flex items-start gap-3\">\n            <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-x-2.5 gap-y-1.5\">\n              <h1 ref={titleRef} className=\"min-w-0 origin-left text-[22px] font-semibold leading-[1.2] tracking-[-0.02em] text-foreground @min-[36rem]:text-[26px]\">\n                <TextMorph animateWidth={false}>{title}</TextMorph>\n              </h1>\n              {badge && (\n                <span ref={badgeRef} className=\"flex shrink-0 items-center\">\n                  {badge}\n                </span>\n              )}\n            </div>\n            {actions.length > 0 && (\n              <div\n                ref={actionsRef}\n                className={`flex shrink-0 items-center gap-2 ${breadcrumbs.length ? \"@max-[36rem]:absolute @max-[36rem]:right-4 @max-[36rem]:top-2.5\" : \"\"}`}\n              >\n                {secondary.map(actionButton)}\n                {secondary.length > 0 && (\n                  <span className=\"@min-[36rem]:hidden\">\n                    <DropdownMenu\n                      align=\"end\"\n                      label=\"More actions\"\n                      items={secondary.map((a) => ({ id: a.id, label: a.label, icon: a.icon, destructive: a.destructive, onSelect: () => run(a) }))}\n                      trigger={\n                        <button\n                          type=\"button\"\n                          aria-label=\"More actions\"\n                          className=\"flex size-9 cursor-pointer items-center justify-center rounded-[10px] text-muted-foreground shadow-[inset_0_0_0_1px_var(--border)] transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n                        >\n                          <Ellipsis className=\"size-4\" aria-hidden=\"true\" />\n                        </button>\n                      }\n                    />\n                  </span>\n                )}\n                {primary.map(actionButton)}\n              </div>\n            )}\n          </div>\n          {description && (\n            <p ref={descRef} key={description} className=\"mt-1.5 max-w-[640px] text-[14px] leading-relaxed text-muted-foreground motion-safe:animate-[ui-empty-in_360ms_cubic-bezier(0.16,1,0.3,1)_backwards]\">\n              {description}\n            </p>\n          )}\n          {meta && (\n            <div ref={metaRef} className=\"mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5 text-[12.5px] text-muted-foreground\">\n              {meta}\n            </div>\n          )}\n        </div>\n        {tabs?.length ? (\n          <div data-tabs=\"\">\n            <TabStrip\n              tabs={tabs}\n              value={tab}\n              linkAs={LinkAs}\n              reduced={reduced}\n              onChange={(id) => {\n                if (tabProp === undefined) setOwnTab(id);\n                onTabChange?.(id);\n              }}\n            />\n          </div>\n        ) : (\n          <span ref={ruleRef} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-border opacity-0\" />\n        )}\n      </header>\n    </>\n  );\n}\n\nfunction BackLink({ crumb, linkAs: LinkAs, compact = false }: { crumb: PageCrumb; linkAs: React.ElementType; compact?: boolean }) {\n  const cls = `flex h-8 cursor-pointer items-center gap-0.5 rounded-[8px] text-[13px] text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 ${\n    compact ? \"w-8 justify-center\" : \"max-w-full pl-1 pr-2\"\n  }`;\n  const body = (\n    <>\n      <ChevronLeft className=\"size-4 shrink-0\" aria-hidden=\"true\" />\n      {compact ? <span className=\"sr-only\">Back to {crumb.label}</span> : <span className=\"min-w-0 truncate\">{crumb.label}</span>}\n    </>\n  );\n  return crumb.href ? (\n    <LinkAs href={crumb.href} onClick={crumb.onClick} className={cls}>\n      {body}\n    </LinkAs>\n  ) : (\n    <button type=\"button\" onClick={crumb.onClick} className={cls}>\n      {body}\n    </button>\n  );\n}\n\nexport default PageHeader;\n"},{"path":"registry/ui-interaction-motion.ts","type":"registry:component","content":"// Hairline UI · page-header · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n'use client';\n\nimport * as React from 'react';\n\nexport const EASE_OUT = 'cubic-bezier(0.16, 1, 0.3, 1)';\nexport const EASE_SETTLE = 'cubic-bezier(0.22, 1.18, 0.36, 1)';\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = 'cubic-bezier(0.34, 1.36, 0.64, 1)';\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  'transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100';\nexport const INTERACTION_FOCUS ='focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\nconst query = '(prefers-reduced-motion: reduce)';\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener('change', notify);\n  return () => media.removeEventListener('change', notify);\n};\nexport const useInteractionReducedMotion = () => React.useSyncExternalStore(subscribe, () => window.matchMedia(query).matches, () => false);\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility(); document.addEventListener('visibilitychange', visibility);\n    return () => { observer.disconnect(); document.removeEventListener('visibilitychange', visibility); };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(on: boolean, reduced: boolean): React.CSSProperties {\n  return { opacity: on ? 1 : 0, transform: on ? 'none' : 'scale(0.6)', filter: on ? 'blur(0px)' : 'blur(3px)', transition: reduced ? 'none' : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}` };\n}\n\n/** A raised object: one tight contact shadow, one short ambient, a hairline of light on its top edge. */\nexport const MATERIAL_LIFT =\n  'shadow-[0_1px_1.5px_rgb(0_0_0/0.07),0_3px_8px_-2px_rgb(0_0_0/0.1),inset_0_0.5px_0_rgb(255_255_255/0.8)] dark:shadow-[0_1px_2px_rgb(0_0_0/0.5),0_4px_10px_-2px_rgb(0_0_0/0.35),inset_0_0.5px_0_rgb(255_255_255/0.1)]';\n/** A trough something sits in, shaded from above, lit along its bottom edge. */\nexport const MATERIAL_RECESS =\n  'shadow-[inset_0_1px_2.5px_rgb(0_0_0/0.09),inset_0_-0.5px_0_rgb(255_255_255/0.7)] dark:shadow-[inset_0_1px_3px_rgb(0_0_0/0.45),inset_0_-0.5px_0_rgb(255_255_255/0.07)]';\n\nexport type SpringConfig = { stiffness: number; damping: number; mass?: number };\nexport interface Spring {\n  get(): number;\n  getVelocity(): number;\n  getTarget(): number;\n  /** Aim somewhere new from wherever it is now, keeping its speed. */\n  set(target: number): void;\n  /** Add speed (units per second), on top of what it already has. */\n  push(velocity: number): void;\n  /** Be there now, at rest. */\n  jump(value: number): void;\n  configure(config: SpringConfig): void;\n  stop(): void;\n}\n\n// Every moving spring on the page shares one frame loop, which sleeps when the last one rests. Each spring's onFrame runs\n// once per frame after all of them have stepped, so several springs that draw one shape paint it once.\nconst SPRING_STEP = 1 / 240;\ntype Running = { step: () => void };\nconst runningSprings = new Set<Running>();\nconst springPainters = new Set<() => void>();\nlet springFrame = 0;\nlet springLast = 0;\nlet springSpare = 0;\n\nfunction springTick(now: number) {\n  // A hidden tab stops the frames, so the first one back must not count the whole gap as time passed.\n  springSpare += Math.min((now - springLast) / 1000, 0.05);\n  springLast = now;\n  while (springSpare >= SPRING_STEP) {\n    runningSprings.forEach((spring) => spring.step());\n    springSpare -= SPRING_STEP;\n  }\n  const painters = [...springPainters];\n  springPainters.clear();\n  painters.forEach((paint) => paint());\n  springFrame = runningSprings.size ? requestAnimationFrame(springTick) : 0;\n}\n\nfunction wakeSprings(spring: Running) {\n  runningSprings.add(spring);\n  if (springFrame) return;\n  springSpare = 0;\n  springFrame = requestAnimationFrame((now) => {\n    springLast = now - 1000 / 60;\n    springTick(now);\n  });\n}\n\n/**\n * A spring that carries its speed: re-aim it mid-flight and it curves on from where it is, push it while it swings and the\n * push adds to the swing. Use it for anything that can be interrupted; a curve restarts from a standstill every time.\n * `onFrame` should write straight to the DOM. `precision` is how close counts as there, in the value's own units.\n */\nexport function createSpring(initial: number, config: SpringConfig, onFrame: () => void, precision = 0.01): Spring {\n  let value = initial;\n  let velocity = 0;\n  let target = initial;\n  let { stiffness, damping, mass = 1 } = config;\n  const running: Running = {\n    step() {\n      velocity += ((-stiffness * (value - target) - damping * velocity) / mass) * SPRING_STEP;\n      value += velocity * SPRING_STEP;\n      if (Math.abs(value - target) < precision && Math.abs(velocity) < precision * 10) {\n        value = target;\n        velocity = 0;\n        runningSprings.delete(running);\n      }\n      springPainters.add(onFrame);\n    },\n  };\n  return {\n    get: () => value,\n    getVelocity: () => velocity,\n    getTarget: () => target,\n    set(next) {\n      if (next === target && !runningSprings.has(running)) return;\n      target = next;\n      wakeSprings(running);\n    },\n    push(speed) {\n      velocity += speed;\n      wakeSprings(running);\n    },\n    jump(next) {\n      value = next;\n      target = next;\n      velocity = 0;\n      runningSprings.delete(running);\n      onFrame();\n    },\n    configure(next) {\n      ({ stiffness, damping, mass = 1 } = next);\n    },\n    stop() {\n      runningSprings.delete(running);\n    },\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(samples: PointerSample[], x: number, time: number) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100) return 0;\n  const first = samples[0], last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(overshoot: number, dimension = 320, constant = 0.55): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(distance: number, velocity: number, time = 0.12): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(velocity: number, distanceToTarget: number, factor = 10): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient = (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value = to + Math.exp(-damping * omega * t) * (displacement * Math.cos(damped * t) + coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n\n"}],"css":{"@keyframes ui-slide-from-right":{"from":{"opacity":"0","transform":"translateX(8px)"},"to":{"opacity":"1","transform":"none"}},"@keyframes ui-empty-in":{"from":{"opacity":"0","transform":"translateY(4px)","filter":"blur(4px)"},"to":{"opacity":"1","transform":"none","filter":"none"}}},"docs":"Docs and live preview: https://hairlineui.com/ui/page-header. MIT licensed: https://hairlineui.com/license#components","meta":{"license":"MIT"}}