<!-- generated by scripts/gen-docs.mjs from docs/system/page-header.md. Edit the source and rerun. -->
# PageHeader

## Description
Heads a record's page: what kind of thing it is, its name as the page's heading, one line about it, its picture and the actions on it, the same height while it loads as when it has loaded.

`import { PageHeader } from "@/components/cobalt/ui/page-header"`, source `registry/cobalt/ui/page-header.tsx`, status `ready`.
Foundation: `hand-rolled`. Traps checked: `trap/loading-layout-shift`, `trap/text-measure`, `trap/narrow-hidden-nav` (n/a: it holds no navigation), `trap/surface-double-edge` (n/a: it has no surface of its own), `trap/weight-shift` (n/a: nothing changes weight between states).

`trap/loading-layout-shift` is answered by the pending state, whose skeleton lines take each line's own height (States). `trap/text-measure` by a name that wraps, balanced, and actions that move under the words below 640px (Limits).

### Foundation
Not applicable: hand-rolled.

| Given by the foundation | Added by the team |
|---|---|
| Not applicable: hand-rolled, a `header` with an `h1` | Slots for the eyebrow, the title, a one-line description, 56px media at the start and up to two actions at the end; the title at the page title's size (`text-2xl font-semibold`); the words keep at least 240px, so the actions move under them on a phone; `pending` for the first load, where a slot written but still empty draws a skeleton line at its own size, a slot that already has words shows them, and media still on its way is a 56px round block; `aria-busy` while pending; `headingLevel` 2 for a header inside a panel |

## Examples
A person's record: what they are, their name, one line about them, their picture, and Save and Export.

Real uses, 0 call sites (`rg -n "<PageHeader\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new. Fund Census draws its profile header by hand, 210px loading and loaded (`docs/research/2026-10-17-fund-census-states.md`, section 2).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/page-header/default.tsx` | default | The head of a person's record: what they are, their name as the page's heading, one line about them, their picture and the two actions on them |
| `docs/system/examples/page-header/pending.tsx` | state:pending | On its first load the header holds each line it will have with a skeleton line of the same size |
| `docs/system/examples/page-header/default.tsx` | state:loaded | Every slot filled |
| `docs/system/examples/page-header/pending.tsx` | composition:Stat | The header over the record's figures, both pending and both loaded |

Example: The head of a person's record: what they are, their name as the page's heading, one line about them, their picture and the two actions on them (`docs/system/examples/page-header/default.tsx`)

```tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/components/cobalt/ui/avatar";
import { Button } from "@/components/cobalt/ui/button";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

export default function Example() {
  const saved = useOptimisticToggle("saved:maya-chen", false, { send: request });
  return (
    <PageHeader
      className="w-full"
      eyebrow="Portfolio manager"
      title="Maya Chen"
      description="Juniper Ridge Advisers, Boston. Manages 4 funds with $4.8B in assets."
      media={
        <Avatar name="Maya Chen" className="size-14">
          <AvatarImage src="/photos/portrait-2.webp" />
          <AvatarFallback />
        </Avatar>
      }
      actions={
        <>
          {/* The labeled form says Save beside its bookmark, and the export beside it takes the same
              small size, so the two sit at one height. */}
          <SaveToggle variant="labeled" pressed={saved.on} onPressedChange={saved.flip} label="Save Maya Chen" />
          <Button variant="secondary" size="sm">
            Export filings
          </Button>
        </>
      }
    />
  );
}
```

Example: The header over the record's figures, both pending and both loaded (`docs/system/examples/page-header/pending.tsx`)

```tsx
import { useEffect, useState } from "react";

import { PageHeader } from "@/components/cobalt/ui/page-header";
import { Stat } from "@/components/cobalt/ui/stat";

type Adviser = { kind: string; name: string; about: string; assets: string; funds: string };

// Stands in for your API call. It answers after 1.5 seconds.
const readAdviser = () =>
  new Promise<Adviser>((resolve) =>
    setTimeout(
      () =>
        resolve({
          kind: "Investment adviser",
          name: "Juniper Ridge Advisers",
          about: "Boston. Registered since 2009.",
          assets: "$4.8B",
          funds: "12",
        }),
      1500,
    ),
  );

export default function Example() {
  const [adviser, setAdviser] = useState<Adviser | null>(null);
  useEffect(() => {
    void readAdviser().then(setAdviser);
  }, []);
  const pending = adviser === null;
  return (
    <div className="flex w-full flex-col gap-6">
      <PageHeader pending={pending} eyebrow={adviser?.kind} title={adviser?.name} description={adviser?.about} />
      <div className="grid grid-cols-2 gap-4">
        <Stat pending={pending} label="Gross assets" value={adviser?.assets} note="As of the June filing" />
        <Stat pending={pending} label="Funds advised" value={adviser?.funds} note="As of the June filing" />
      </div>
    </div>
  );
}
```

## Variants
Not applicable: one shape. `headingLevel` sets the heading's level and nothing else.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| loaded | `pending` false | read it; press an action | the words, the picture and the actions | test |
| pending | `pending` true | wait; press an action that does not need the record | a skeleton line in each written slot still empty, a 56px round block for media on its way, the slots that have words; `aria-busy` | test |

Example: On its first load the header holds each line it will have with a skeleton line of the same size (`docs/system/examples/page-header/pending.tsx`)

```tsx
import { useEffect, useState } from "react";

import { PageHeader } from "@/components/cobalt/ui/page-header";
import { Stat } from "@/components/cobalt/ui/stat";

type Adviser = { kind: string; name: string; about: string; assets: string; funds: string };

// Stands in for your API call. It answers after 1.5 seconds.
const readAdviser = () =>
  new Promise<Adviser>((resolve) =>
    setTimeout(
      () =>
        resolve({
          kind: "Investment adviser",
          name: "Juniper Ridge Advisers",
          about: "Boston. Registered since 2009.",
          assets: "$4.8B",
          funds: "12",
        }),
      1500,
    ),
  );

export default function Example() {
  const [adviser, setAdviser] = useState<Adviser | null>(null);
  useEffect(() => {
    void readAdviser().then(setAdviser);
  }, []);
  const pending = adviser === null;
  return (
    <div className="flex w-full flex-col gap-6">
      <PageHeader pending={pending} eyebrow={adviser?.kind} title={adviser?.name} description={adviser?.about} />
      <div className="grid grid-cols-2 gap-4">
        <Stat pending={pending} label="Gross assets" value={adviser?.assets} note="As of the June filing" />
        <Stat pending={pending} label="Funds advised" value={adviser?.funds} note="As of the June filing" />
      </div>
    </div>
  );
}
```

Example: Every slot filled (`docs/system/examples/page-header/default.tsx`)

```tsx
import { Avatar, AvatarFallback, AvatarImage } from "@/components/cobalt/ui/avatar";
import { Button } from "@/components/cobalt/ui/button";
import { PageHeader } from "@/components/cobalt/ui/page-header";
import { SaveToggle } from "@/components/cobalt/ui/save-toggle";
import { useOptimisticToggle } from "@/lib/cobalt/use-optimistic-toggle";

// Stands in for your API call. It answers after 600ms, and fails while the browser is offline or the
// address has ?network=offline.
const request = () =>
  new Promise<void>((resolve, reject) =>
    setTimeout(() => {
      const offline = !navigator.onLine || new URLSearchParams(location.search).get("network") === "offline";
      if (offline) reject(new Error("offline"));
      else resolve();
    }, 600),
  );

export default function Example() {
  const saved = useOptimisticToggle("saved:maya-chen", false, { send: request });
  return (
    <PageHeader
      className="w-full"
      eyebrow="Portfolio manager"
      title="Maya Chen"
      description="Juniper Ridge Advisers, Boston. Manages 4 funds with $4.8B in assets."
      media={
        <Avatar name="Maya Chen" className="size-14">
          <AvatarImage src="/photos/portrait-2.webp" />
          <AvatarFallback />
        </Avatar>
      }
      actions={
        <>
          {/* The labeled form says Save beside its bookmark, and the export beside it takes the same
              small size, so the two sit at one height. */}
          <SaveToggle variant="labeled" pressed={saved.on} onPressedChange={saved.flip} label="Save Maya Chen" />
          <Button variant="secondary" size="sm">
            Export filings
          </Button>
        </>
      }
    />
  );
}
```

### State precedence
- Pending and a slot with words: both show. The words show and only the empty slots hold bars.
- Pending and loaded: Not applicable: `pending` is one or the other.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| a skeleton line appears | announce | Skeleton's: clear for 250ms, then `duration-fade`, then the pulse | opacity | no pulse; the line holds still |

## Props

<!-- Props generated from registry/cobalt/ui/page-header.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `title` | `ReactNode` |  | The record's name, the page's heading. |
| `actions?` | `ReactNode` |  | One or two actions on the record: a `SaveToggle`, an export. |
| `description?` | `ReactNode` |  | One line about it: where it is, when it began, what it holds. |
| `eyebrow?` | `ReactNode` |  | What kind of thing the page is about, above its name: "Investment adviser". |
| `headingLevel?` | `1 \| 2` |  | 1 when the header heads the page, 2 when it heads a panel inside one. |
| `media?` | `ReactNode` |  | A picture at the start: an `Avatar` at `size-14`, or a logo of the same size. |
| `pending?` | `boolean` |  | The first load: written slots that are still empty hold their place with skeleton lines. |

Also accepts every native HTML attribute.

`eyebrow` says what kind of thing the page is about. `title` is its name, the heading. `description` is one line about it. `media` is a 56px picture at the start. `actions` are one or two actions at the end. `pending` is the first load. `headingLevel` is 1, or 2 inside a panel. Every `header` attribute passes through.

## Usage

### When to use
- A record's page: a fund, an adviser, a person, a booking.
- A panel that shows one record beside a list, with `headingLevel={2}`.

### When not to use
- A section of a page. Use Section instead.
- The app's top bar. Use Nav instead.
- A list's title with its count and filters. Use Section instead.

### Rules
- `rule/page-header-same-element-loading`: When the record loads, render the same `PageHeader` with `pending` and the slots read from the record, such as `description={data?.city}`, instead of a separate loading header, because the slots it is written with are the lines it holds, so it keeps its height. Evidence: person D37; measured Fund Census's header at 210px loading and loaded, docs/research/2026-10-17-fund-census-states.md section 2. Check: test `page-header.test.tsx` "pending, a written slot still empty holds its line".
  - Don't: `{data ? <PageHeader title={data.name} /> : <Skeleton className="h-16" />}`
  - Do: `<PageHeader pending={!data} title={data?.name} description={data?.city} />`
- `rule/page-header-carry-the-name`: When the person came from a list that already shows the record's name, pass it as `title` while pending, instead of a bar, because the name they pressed is the one thing they already know. Evidence: principle heuristic: visibility of system status; single use docs/system/examples/page-problem/default.tsx:41, the header pending under the record it opens. Check: review.
  - Don't: `<PageHeader pending title={undefined} />` after a press on "Juniper Ridge Advisers"
  - Do: `<PageHeader pending title={fromList.name} description={data?.city} />`

### Content
- Follows `rule/writing-no-invented-numbers`.
- `rule/page-header-eyebrow-kind`: When writing `eyebrow`, name the kind of record in at most 4 words, such as "Investment adviser", instead of a breadcrumb or the section's name, because it says what the page is about, and BackLink says where it sits. Evidence: principle heuristic: recognition rather than recall. Check: review.
  - Don't: `<PageHeader eyebrow="Home / Advisers / Massachusetts" title="Juniper Ridge Advisers" />`
  - Do: `<PageHeader eyebrow="Investment adviser" title="Juniper Ridge Advisers" />`

### Anti-slop
- `rule/page-header-two-actions`: When adding actions, keep to at most 2, such as Save and Export, and put the rest in a DropdownMenu, instead of a row of buttons, because past 2 the actions crowd the name on a phone. Evidence: principle heuristic: aesthetic and minimalist design. Check: review.
  - Don't: `actions={<><Button>Follow</Button><Button>Export</Button><Button>Share</Button><Button>Compare</Button></>}`
  - Do: `actions={<><SaveToggle variant="labeled" label="Save Maya Chen" /><Button variant="secondary" size="sm">Export filings</Button></>}`

### Limits
- `rule/page-header-title-length`: When a name runs past 60 characters, keep it, since it is the record's name, and keep the description to one sentence, because an 88-character name already takes 4 lines at 390 and 5 at 320. Evidence: measured the 88-character name on 5 lines at 320 and 4 lines at 390, with no sideways scroll, docs/system/stress/page-header.tsx. Check: probe docs/system/stress/page-header.tsx on the break-ui harness at 320.
  - Don't: `<PageHeader title="Juniper Ridge" description="A long paragraph about the adviser's history, people, offices and every fund it runs." />`
  - Do: `<PageHeader title="Juniper Ridge Advisers Global Long-Short Opportunities Master Fund Limited Partnership" description="Boston, registered since 2009." />`

- `rule/page-header-description-one-line`: When the description may load into a pending header, keep it to one line at 390, about 40 characters, instead of a sentence that wraps, because the skeleton holds one line and a description that arrives on 2 lines grows the header and moves everything under it. Evidence: measured a 58-character description growing the header by 20px when it arrived at 390, and a 30-character one by 0px, docs/system/examples/page-header/pending.tsx (Playwright, 2026-10-17). Check: probe docs/system/stress/page-header.tsx on the break-ui harness at 390.
  - Don't: `<PageHeader pending={!data} description={data?.about} />` with "Boston, Massachusetts. Registered with the SEC since 2009."
  - Do: `<PageHeader pending={!data} description={data?.about} />` with "Boston. Registered since 2009."

## Accessibility
Rests on a `header` with an `h1`, or an `h2` with `headingLevel={2}`.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | before the header | moves to the first action; the words take no focus | the first action | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| root | banner only at the top of the body; otherwise none | none | `aria-busy` while pending | nothing of its own | test |
| title | heading, level 1 or 2 | its text | none | the name, as the page's heading | test |
| skeleton line | none, `aria-hidden` | none | none | nothing | test |

## Tokens
| Part | State | Token |
|---|---|---|
| title | all | `--foreground`, `--text-2xl` |
| eyebrow, description | all | `--muted-foreground` |
| skeleton | pending | Skeleton's tokens |

## Related
- Stat: the figures under the header, pending the same way.
- DataList: the facts under it, pending the same way.
- PageProblem: what the page shows when the record could not load.
- Section: a titled block inside the page.
- BackLink: the way back to the list the record came from.
