# Page header

> Project page header with breadcrumbs, status badge, compact sticky toggle, primary actions and live-counted section tabs.

- Kind: block · Category: App shell · Interactivity: script
- Install: `npx shadcn@latest add @haze/page-header`
- File: `src/components/haze/blocks/page-header.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/blocks/page-header

## Use when
- Framing a project or workspace view with breadcrumbs, status metadata and counted section tabs
- Offering a compact sticky header mode that hides secondary metadata while scrolling

## Avoid when
- Building a top marketing site navigation bar; use navbar-simple or navbar-centered

## Alternatives
- [breadcrumb](https://hazeui.com/ui/breadcrumb.md)
- [tabs](https://hazeui.com/ui/tabs.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` | "haze-page-header" | no | Unique prefix for section heading IDs. |
| project | `string` | "Checkout Redesign" | no | Project title shown in the breadcrumb and heading. |
| tabs | `{ id: string; label: string; count: number; summary: string }[]` | 3 project tabs | no | Section tabs with tabular item counters. |
| class | `string` |  | no | Extra classes on the outer section. |

## Accessibility
- Breadcrumbs sit in a labelled nav landmark and section tabs expose role="tab" with aria-selected.
- Compact mode, Share and New issue actions announce updates via a polite role="status" message.
- Key Tab: Move across Compact, Share, New issue and section tabs
- Key Enter / Space: Toggle compact mode, switch tabs or increment the issue counter

## Agent prompts

### Install and use

Install the Haze UI block "Page header" with `npx shadcn@latest add @haze/page-header`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import PageHeader from "@/components/haze/blocks/page-header.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/blocks/page-header.md

### Customize with real content

Adapt the Haze page-header block for our product. Replace the demo values of these props with our real content: id, project, tabs, class. Keep the layout, the heading level rules and these accessibility details: Breadcrumbs sit in a labelled nav landmark and section tabs expose role="tab" with aria-selected. Compact mode, Share and New issue actions announce updates via a polite role="status" message. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using page-header, check it fits: use it when framing a project or workspace view with breadcrumbs, status metadata and counted section tabs; offering a compact sticky header mode that hides secondary metadata while scrolling. Avoid it when building a top marketing site navigation bar; use navbar-simple or navbar-centered. Alternatives: @haze/breadcrumb, @haze/tabs.

## Example requests that should lead here
- Create a project page header with breadcrumb, status badge, compact toggle and live-counted section tabs

## Source

```astro
---
import { ChevronRight, GitBranch, Minimize2, Plus, Share2 } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface HeaderTab {
  id: string;
  label: string;
  count: number;
  summary: string;
}

interface Props {
  id?: string;
  project?: string;
  tabs?: HeaderTab[];
  class?: string;
}

const {
  id = "haze-page-header",
  project = "Checkout Redesign",
  tabs = [
    { id: "overview", label: "Overview", count: 12, summary: "12 active milestones tracked across web and mobile checkout flows." },
    { id: "issues", label: "Issues", count: 28, summary: "28 open issues (4 high priority, 9 ready for QA review)." },
    { id: "deploys", label: "Deployments", count: 6, summary: "6 staging and production builds deployed in the last 48 hours." },
  ],
  class: className,
} = Astro.props;
const firstTab = tabs[0];
---

<section aria-labelledby={`${id}-title`} data-haze-page-header class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
  <div class="mx-auto max-w-4xl overflow-hidden rounded-2xl border border-border bg-card">
    <header data-ph-head data-compact="false" class="border-b border-border bg-muted/40 px-5 py-4 transition-[padding] duration-200 ease-snappy data-[compact=true]:py-2.5 sm:px-6">
      <nav data-ph-crumb aria-label="Breadcrumb" class="mb-2 flex items-center gap-1.5 text-xs text-muted-foreground">
        <span>Projects</span>
        <ChevronRight class="size-3" aria-hidden="true" />
        <span class="text-foreground">{project}</span>
      </nav>

      <div class="flex flex-wrap items-center justify-between gap-3">
        <div class="flex min-w-0 flex-wrap items-center gap-2.5">
          <h2 id={`${id}-title`} class="text-lg/7 font-semibold tracking-tight text-foreground sm:text-xl/7">{project}</h2>
          <span class="inline-flex items-center gap-1.5 rounded-full border border-frame-success bg-success/10 px-2.5 py-0.5 text-[0.6875rem] font-medium text-success">On track</span>
          <span data-ph-meta class="inline-flex items-center gap-1 font-mono text-xs text-muted-foreground">
            <GitBranch class="size-3.5" aria-hidden="true" />
            main
          </span>
        </div>

        <div class="flex flex-wrap items-center gap-2">
          <button type="button" data-ph-fold aria-pressed="false" class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-2.5 text-xs font-medium text-muted-foreground hover:border-frame-strong hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
            <Minimize2 class="size-3.5" aria-hidden="true" />
            <span>Compact</span>
          </button>
          <button type="button" data-ph-share class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-3 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
            <Share2 class="size-3.5" aria-hidden="true" />
            Share
          </button>
          <button type="button" data-ph-new class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
            <Plus class="size-3.5" aria-hidden="true" />
            New issue
          </button>
        </div>
      </div>

      <div role="tablist" aria-label="Project sections" hidden={!firstTab} class="mt-4 flex flex-wrap gap-1 border-t border-border pt-3">
        {
          tabs.map((t, i) => (
            <button
              type="button"
              role="tab"
              data-ph-tab={t.id}
              data-ph-summary={t.summary}
              aria-selected={i === 0 ? "true" : "false"}
              class="inline-flex h-8 cursor-pointer items-center gap-2 rounded-lg px-3 text-xs font-medium text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground aria-selected:bg-card aria-selected:text-foreground aria-selected:shadow-key focus-visible:outline-2 focus-visible:outline-ring"
            >
              <span>{t.label}</span>
              <span data-ph-count={t.id} class="rounded-sm bg-muted px-1.5 py-0.5 font-mono text-[0.6875rem] tabular-nums">{t.count}</span>
            </button>
          ))
        }
      </div>
    </header>

    <div class="p-5 sm:p-6">
      <p data-ph-body class="text-sm/6 text-pretty text-foreground">{firstTab?.summary ?? "No project sections are available."}</p>
      <p data-ph-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
    </div>
  </div>
</section>

<script>
  function initPageHeaders() {
    document.querySelectorAll<HTMLElement>("[data-haze-page-header]").forEach((root) => {
      if (root.hasAttribute("data-enhanced")) return;
      root.setAttribute("data-enhanced", "");
      const head = root.querySelector<HTMLElement>("[data-ph-head]");
      const crumb = root.querySelector<HTMLElement>("[data-ph-crumb]");
      const meta = root.querySelector<HTMLElement>("[data-ph-meta]");
      const body = root.querySelector<HTMLElement>("[data-ph-body]");
      const status = root.querySelector<HTMLElement>("[data-ph-status]");

      root.querySelector<HTMLButtonElement>("[data-ph-fold]")?.addEventListener("click", (ev) => {
        const btn = ev.currentTarget as HTMLButtonElement;
        const compact = head?.dataset.compact !== "true";
        if (head) head.dataset.compact = String(compact);
        if (crumb) crumb.hidden = compact;
        if (meta) meta.hidden = compact;
        btn.setAttribute("aria-pressed", String(compact));
        if (status) status.textContent = compact ? "Switched to compact sticky header mode." : "Restored full project header.";
      });

      root.querySelectorAll<HTMLButtonElement>("[data-ph-tab]").forEach((tab) => {
        tab.addEventListener("click", () => {
          root.querySelectorAll<HTMLButtonElement>("[data-ph-tab]").forEach((t) => t.setAttribute("aria-selected", String(t === tab)));
          if (body) body.textContent = tab.dataset.phSummary ?? "";
        });
      });

      root.querySelector<HTMLButtonElement>("[data-ph-new]")?.addEventListener("click", () => {
        const c = root.querySelector<HTMLElement>('[data-ph-count="issues"]');
        if (c) c.textContent = String(Number(c.textContent ?? 28) + 1);
        if (status) status.textContent = "Created a new issue and incremented the Issues tab count.";
      });

      root.querySelector<HTMLButtonElement>("[data-ph-share]")?.addEventListener("click", () => {
        if (status) status.textContent = "Copied project URL to clipboard.";
      });
    });
  }
  initPageHeaders();
  document.addEventListener("astro:page-load", initPageHeaders);
</script>
```
