# Page Header

The strip at the top of a screen's content: a title, a description, a back link and the actions.

The strip at the top of a screen's content (not the app's top bar): a title that is a real heading, an optional description, an optional back link above it, and the actions at the end of the title's line. Nothing is cut: the title and the description wrap, and when the actions do not fit beside 10rem of text (8rem in a pane) they drop to their own line under it (on a phone). size="page" is a page's one title (20px/600); size="pane" is the one-row header of a pane above a list (13px/600, the description beside the title, a hairline under the row). Static: nothing moves but the back link's colour.

Kind: component · Category: Navigation · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add page-header
```

It writes the folder `page-header/` into the project's ui folder (`index.ts`, `page-header.tsx`, `PageHeader.vue`, `PageHeader.svelte`, `page-header.recipe.ts`), and what it is built from: [Button](/components/button.md), [Link](/components/link.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { PageHeader } from "@/components/ui/page-header";
```

```vue
import { PageHeader } from "@/components/ui/page-header";
```

```svelte
import { PageHeader } from "$lib/components/ui/page-header";
```

## Parts

In the DOM the root carries `data-slot="page-header"` and each part `data-slot="page-header-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `page-header` |  | page: a column (back link, then the row), gap 4px, no padding or edge of its own: it sits in the page's content column. pane: one wrapping row, at least 44px tall, 16px in at both ends, 8px block padding, a line hairline under it; the back link sits on the title's first line (baseline) and the lines are centred in the row. Extra attributes (id, aria-*) land on it. |
| `back` | `a \| button` | `page-header-back` | optional | The back link: an <a> when back has an href, a <button type="button"> calling onBack when it has none. The Link recipe (standalone, neutral), laid out in the page's direction (bidi isolate), so the arrow is at the page's start whatever the label's script: 13px on a 20px line, ink-2, ink and underlined on hover, a taller hit area on coarse pointers; a 14px arrow-left before the label, mirrored right-to-left. Never cut: wraps anywhere. |
| `row` | `div` | `page-header-row` |  | The text and the actions: a wrapping row, 16px between them across. page: aligned to the top (the actions on the title's 28px line), 12px between lines when the actions drop. pane: centred. |
| `text` | `div` | `page-header-text` |  | The title and the description; takes the free space and keeps at least 10rem before the actions wrap (8rem in a pane, so a short pane title and its action stay on one row at phone width). page: a column, 4px gap. pane: a wrapping line, the description beside the title on its baseline. |
| `title` | `h1 \| h2 \| h3 \| h4 \| h5 \| h6` | `page-header-title` |  | The heading (level, h1 by default). page: 20px/600 on a 28px line. pane: 13px/600 on a 20px line. ink. Wraps anywhere, never cut; author text keeps its own direction and its alignment on the page's side. |
| `description` | `p` | `page-header-description` | optional | ink-2 (it is read: a count, a state, what the screen holds). page: 13px on a 20px line under the title. pane: 12px on a 20px line beside it. Wraps anywhere. |
| `actions` | `div` | `page-header-actions` | optional | At the end of the title's line: the host's Buttons (React: a node; Vue: the actions slot; Svelte: a snippet), or Buttons built from data (sm, outline unless given). 8px apart, wrapping among themselves; on their own line under the text when they do not fit beside it. |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `node (children / slot)` |  | The screen's title, rendered as a real heading. React: a node; Vue: a string or the title slot; Svelte: a string or a snippet. |
| `description` | `node (children / slot)` |  | Optional: what the screen holds or its state ("42 open · updated 2 min ago"). React: a node; Vue: a string or the description slot; Svelte: a string or a snippet. |
| `back` | `object` |  | Optional back link above the title (before it in a pane): the page it returns to, by name ("Projects", not "Back"). With an href it is a link; without one, a button that calls onBack. |
| `level` | `number` | `1` | The heading's level, 1 to 6. A screen's one title is h1; a header inside a region that already has its h1 (a pane beside the main view, a section of a settings page) takes the next level. The size never follows the level. |
| `size` | `"page" \| "pane"` | `"page"` | page: a page's one title (Settings, History, Issues), 20px/600, the description under it. pane: the header row of a pane above a list (an inbox beside a preview), 13px/600, the description beside the title, at least 44px tall with a hairline under it. |
| `actions` | `ReactNode \| ReadonlyArray<PageHeaderAction>` |  | The actions at the end of the title's line: your own Buttons (React: a node; Vue: the actions slot; Svelte: a snippet), usually sm, at most one filled; or Buttons from data (sm, outline unless given), which call onAction. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `back` | (back) when the back button is pressed, or a back link clicked. React onBack, Vue @back, Svelte onback. With an href it replaces the browser's navigation (client routers); a click with a modifier key keeps the browser's. |
| `action` | (value: string) when a data action is pressed. React onAction, Vue @action, Svelte onaction. |

## Slots

| Slot | Content |
| --- | --- |
| `title` | Vue: a rich title in place of the title prop (Svelte: title as a snippet; React: title as a node). |
| `description` | Vue: a rich description in place of the description prop (Svelte: a snippet; React: a node). |
| `actions` | Vue: your own Buttons at the end of the title's line (React: actions as a node; Svelte: actions as a snippet). |

## States

`hover`, `press`, `focus-visible`

## Keyboard and accessibility

Role: none (a heading, a link or button, and the host's buttons).

Keyboard:

- Tab reaches the back link, then each action; the title is not a stop
- Enter follows the back link; Enter or Space presses the back button

Notes:

- The title is a real heading (h1 by default), so the screen has its name in the document outline; set level for a header inside a region that already has its h1.
- The back link names where it goes ("Projects"); its arrow is aria-hidden.
- No landmark: the root is a div, so a page header inside the main content never becomes a second banner.

## Motion

- back link: colour over duration.fast (hover gated to a fine pointer), the press at once
- the actions: the Buttons' own
- nothing else moves; nothing plays on first paint

## Tokens

`color.ink`, `color.ink-2`, `color.line`, `text.xl`, `text.sm`, `text.xs`, `duration.fast`

## Dependencies

- [Button](/components/button.md)
- [Link](/components/link.md)

## Notes

- Replaces the hand-built page titles of a screen: an h1 with a Button beside it, a pane's title row with a count and a Mark all as read.

## Examples

### A project's issues, above their table

React · `issues.tsx`

```tsx
import { Funnel, Plus } from "@phosphor-icons/react";
import { Avatar } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const issues = [
  { id: "NW-482", title: "Add retry to webhook delivery", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
  { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
  { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
] as const;

/* the top of a screen: the way back to the project, the title and its state, the actions at the
 * far end of the content column, and the content they act on starting on the title's edge.
 * Narrow, the actions drop under the description and the table scrolls sideways */
export default function Issues() {
  return (
    <div className="flex w-[720px] max-w-full flex-col gap-6">
      <PageHeader
        title="Issues"
        description="42 open · 3 assigned to you"
        back={{ label: "billing-api", href: "/projects/billing-api" }}
        actions={
          <>
            <Button size="sm" icon={<Funnel data-slot="icon" weight="bold" />}>Filter</Button>
            <Button size="sm" variant="primary" icon={<Plus data-slot="icon" weight="bold" />}>New issue</Button>
          </>
        }
      />
      <Table aria-label="Open issues">
        <TableHeader>
          <TableRow>
            <TableHead>ID</TableHead>
            <TableHead className="min-w-48">Title</TableHead>
            <TableHead>Status</TableHead>
            <TableHead>Assignee</TableHead>
            <TableHead numeric>Updated</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {issues.map((issue) => (
            <TableRow key={issue.id}>
              <TableCell className="whitespace-nowrap font-mono text-xs text-ink-2">{issue.id}</TableCell>
              <TableCell>{issue.title}</TableCell>
              <TableCell><StatusPill tone={issue.tone} size="sm">{issue.status}</StatusPill></TableCell>
              <TableCell><Avatar initials={issue.assignee} color={issue.color} size="20" /></TableCell>
              <TableCell numeric className="whitespace-nowrap text-ink-2">{issue.updated}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  );
}
```

Vue · `issues.vue`

```vue
<script setup lang="ts">
import { PhFunnel, PhPlus } from "@phosphor-icons/vue";
import { Avatar } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const issues = [
  { id: "NW-482", title: "Add retry to webhook delivery", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
  { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
  { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
] as const;
</script>

<!-- the top of a screen: the way back to the project, the title and its state, the actions at the
     far end of the content column, and the content they act on starting on the title's edge.
     Narrow, the actions drop under the description and the table scrolls sideways -->
<template>
  <div class="flex w-[720px] max-w-full flex-col gap-6">
    <PageHeader title="Issues" description="42 open · 3 assigned to you" :back="{ label: 'billing-api', href: '/projects/billing-api' }">
      <template #actions>
        <Button size="sm">
          <template #icon><PhFunnel data-slot="icon" weight="bold" /></template>
          Filter
        </Button>
        <Button size="sm" variant="primary">
          <template #icon><PhPlus data-slot="icon" weight="bold" /></template>
          New issue
        </Button>
      </template>
    </PageHeader>
    <Table aria-label="Open issues">
      <TableHeader>
        <TableRow>
          <TableHead>ID</TableHead>
          <TableHead class="min-w-48">Title</TableHead>
          <TableHead>Status</TableHead>
          <TableHead>Assignee</TableHead>
          <TableHead numeric>Updated</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow v-for="issue in issues" :key="issue.id">
          <TableCell class="whitespace-nowrap font-mono text-xs text-ink-2">{{ issue.id }}</TableCell>
          <TableCell>{{ issue.title }}</TableCell>
          <TableCell><StatusPill :tone="issue.tone" size="sm">{{ issue.status }}</StatusPill></TableCell>
          <TableCell><Avatar :initials="issue.assignee" :color="issue.color" size="20" /></TableCell>
          <TableCell numeric class="whitespace-nowrap text-ink-2">{{ issue.updated }}</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  </div>
</template>
```

Svelte · `issues.svelte`

```svelte
<script lang="ts">
  import Funnel from "phosphor-svelte/lib/FunnelIcon";
  import Plus from "phosphor-svelte/lib/PlusIcon";
  import { Avatar } from "$lib/components/ui/avatar";
  import { Button } from "$lib/components/ui/button";
  import { PageHeader } from "$lib/components/ui/page-header";
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const issues = [
    { id: "NW-482", title: "Add retry to webhook delivery", status: "In review", tone: "accent", assignee: "PR", color: "var(--fndn-tag-purple)", updated: "2 min ago" },
    { id: "NW-479", title: "Usage alerts fire twice for the same threshold", status: "In progress", tone: "orange", assignee: "DO", color: "var(--fndn-tag-blue)", updated: "1 h ago" },
    { id: "NW-471", title: "Invoice PDF cuts the tax line", status: "Todo", tone: "neutral", assignee: "AT", color: "var(--fndn-tag-green)", updated: "Nov 14" },
  ] as const;
</script>

<!-- the top of a screen: the way back to the project, the title and its state, the actions at the
     far end of the content column, and the content they act on starting on the title's edge.
     Narrow, the actions drop under the description and the table scrolls sideways -->
<div class="flex w-[720px] max-w-full flex-col gap-6">
  <PageHeader title="Issues" description="42 open · 3 assigned to you" back={{ label: "billing-api", href: "/projects/billing-api" }}>
    {#snippet actions()}
      <Button size="sm">
        {#snippet icon()}<Funnel data-slot="icon" weight="bold" />{/snippet}
        Filter
      </Button>
      <Button size="sm" variant="primary">
        {#snippet icon()}<Plus data-slot="icon" weight="bold" />{/snippet}
        New issue
      </Button>
    {/snippet}
  </PageHeader>
  <Table aria-label="Open issues">
    <TableHeader>
      <TableRow>
        <TableHead>ID</TableHead>
        <TableHead class="min-w-48">Title</TableHead>
        <TableHead>Status</TableHead>
        <TableHead>Assignee</TableHead>
        <TableHead numeric>Updated</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      {#each issues as issue (issue.id)}
        <TableRow>
          <TableCell class="whitespace-nowrap font-mono text-xs text-ink-2">{issue.id}</TableCell>
          <TableCell>{issue.title}</TableCell>
          <TableCell><StatusPill tone={issue.tone} size="sm">{issue.status}</StatusPill></TableCell>
          <TableCell><Avatar initials={issue.assignee} color={issue.color} size="20" /></TableCell>
          <TableCell numeric class="whitespace-nowrap text-ink-2">{issue.updated}</TableCell>
        </TableRow>
      {/each}
    </TableBody>
  </Table>
</div>
```

### A deploy and its state, back through the router

React · `deploy-detail.tsx`

```tsx
import { ArrowClockwise, ArrowSquareOut } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { CodeBlock } from "@/components/ui/code-block";
import { PageHeader } from "@/components/ui/page-header";
import { StatusPill } from "@/components/ui/status-pill";

const log = [
  "Cloning northwind/web-app on main at a1b2c3d",
  "Restored the build cache of dpl_5e1d07",
  "Running \"pnpm install --frozen-lockfile\"",
  "Packages: +1,284 (412 reused)",
  "Running \"pnpm build\"",
  "✓ 214 modules transformed, dist/ is 1.8 MB",
  "Uploading the build output to fra1 and iad1",
  "Assigned app.northwind.example",
  "Deploy ready in 43s",
].join("\n");

/* no href: the back link is a button and the app's router goes back; the description carries the
 * deploy's state, so the screen says what it is before the log does */
export default function DeployDetail() {
  return (
    <div className="flex w-[720px] max-w-full flex-col gap-6">
      <PageHeader
        title={<span className="font-mono">dpl_7f3a9c</span>}
        description={
          <span className="inline-flex items-center gap-2">
            <StatusPill tone="green" size="sm">Ready</StatusPill>
            Production · a1b2c3d on main · 2 min ago
          </span>
        }
        back={{ label: "Deploys" }}
        onBack={() => history.back()}
        actions={
          <>
            <Button size="sm" icon={<ArrowSquareOut data-slot="icon" weight="bold" />}>Visit</Button>
            <Button size="sm" icon={<ArrowClockwise data-slot="icon" weight="bold" />}>Redeploy</Button>
          </>
        }
      />
      <CodeBlock className="max-w-none" variant="code" filename="Build log" value={log} maxHeight={240} />
    </div>
  );
}
```

Vue · `deploy-detail.vue`

```vue
<script setup lang="ts">
import { PhArrowClockwise, PhArrowSquareOut } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { CodeBlock } from "@/components/ui/code-block";
import { PageHeader } from "@/components/ui/page-header";
import { StatusPill } from "@/components/ui/status-pill";

const log = [
  "Cloning northwind/web-app on main at a1b2c3d",
  "Restored the build cache of dpl_5e1d07",
  "Running \"pnpm install --frozen-lockfile\"",
  "Packages: +1,284 (412 reused)",
  "Running \"pnpm build\"",
  "✓ 214 modules transformed, dist/ is 1.8 MB",
  "Uploading the build output to fra1 and iad1",
  "Assigned app.northwind.example",
  "Deploy ready in 43s",
].join("\n");

const goBack = () => history.back();
</script>

<!-- no href: the back link is a button and the app's router goes back; the description carries the
     deploy's state, so the screen says what it is before the log does -->
<template>
  <div class="flex w-[720px] max-w-full flex-col gap-6">
    <PageHeader :back="{ label: 'Deploys' }" @back="goBack">
      <template #title><span class="font-mono">dpl_7f3a9c</span></template>
      <template #description>
        <span class="inline-flex items-center gap-2">
          <StatusPill tone="green" size="sm">Ready</StatusPill>
          Production · a1b2c3d on main · 2 min ago
        </span>
      </template>
      <template #actions>
        <Button size="sm">
          <template #icon><PhArrowSquareOut data-slot="icon" weight="bold" /></template>
          Visit
        </Button>
        <Button size="sm">
          <template #icon><PhArrowClockwise data-slot="icon" weight="bold" /></template>
          Redeploy
        </Button>
      </template>
    </PageHeader>
    <CodeBlock class="max-w-none" variant="code" filename="Build log" :value="log" :max-height="240" />
  </div>
</template>
```

Svelte · `deploy-detail.svelte`

```svelte
<script lang="ts">
  import ArrowClockwise from "phosphor-svelte/lib/ArrowClockwiseIcon";
  import ArrowSquareOut from "phosphor-svelte/lib/ArrowSquareOutIcon";
  import { Button } from "$lib/components/ui/button";
  import { CodeBlock } from "$lib/components/ui/code-block";
  import { PageHeader } from "$lib/components/ui/page-header";
  import { StatusPill } from "$lib/components/ui/status-pill";

  const log = [
    "Cloning northwind/web-app on main at a1b2c3d",
    "Restored the build cache of dpl_5e1d07",
    "Running \"pnpm install --frozen-lockfile\"",
    "Packages: +1,284 (412 reused)",
    "Running \"pnpm build\"",
    "✓ 214 modules transformed, dist/ is 1.8 MB",
    "Uploading the build output to fra1 and iad1",
    "Assigned app.northwind.example",
    "Deploy ready in 43s",
  ].join("\n");
</script>

<!-- no href: the back link is a button and the app's router goes back; the description carries the
     deploy's state, so the screen says what it is before the log does -->
{#snippet title()}<span class="font-mono">dpl_7f3a9c</span>{/snippet}
{#snippet description()}
  <span class="inline-flex items-center gap-2">
    <StatusPill tone="green" size="sm">Ready</StatusPill>
    Production · a1b2c3d on main · 2 min ago
  </span>
{/snippet}
<div class="flex w-[720px] max-w-full flex-col gap-6">
  <PageHeader {title} {description} back={{ label: "Deploys" }} onback={() => history.back()}>
    {#snippet actions()}
      <Button size="sm">
        {#snippet icon()}<ArrowSquareOut data-slot="icon" weight="bold" />{/snippet}
        Visit
      </Button>
      <Button size="sm">
        {#snippet icon()}<ArrowClockwise data-slot="icon" weight="bold" />{/snippet}
        Redeploy
      </Button>
    {/snippet}
  </PageHeader>
  <CodeBlock class="max-w-none" variant="code" filename="Build log" value={log} maxHeight={240} />
</div>
```

### The header of a pane above its list

React · `inbox-pane.tsx`

```tsx
import { useState } from "react";
import { Avatar } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { ScrollArea } from "@/components/ui/scroll-area";

const notifications = [
  { id: 1, who: "Priya Raman", initials: "PR", color: "var(--fndn-tag-purple)", what: "requested your review on #482 Add retry to webhook delivery", when: "2 min", unread: true },
  { id: 2, who: "Daniel Okafor", initials: "DO", color: "var(--fndn-tag-blue)", what: "assigned you NW-479 Usage alerts fire twice", when: "1 h", unread: true },
  { id: 3, who: "Aiko Tanaka", initials: "AT", color: "var(--fndn-tag-green)", what: "mentioned you in NW-471 Invoice PDF cuts the tax line", when: "3 h", unread: true },
  { id: 4, who: "Lucas Moreau", initials: "LM", color: "var(--fndn-tag-cyan)", what: "closed NW-466 Retry button stays disabled", when: "Nov 14", unread: false },
  { id: 5, who: "Sofia Alvarez", initials: "SA", color: "var(--fndn-tag-orange)", what: "commented on NW-458 Export usage as CSV", when: "Nov 12", unread: false },
];

/* size="pane": the one-row header of a list in a pane, the count beside the title, its action at
 * the end; the rows under it start on the title's 16px edge */
export default function InboxPane() {
  const [items, setItems] = useState(notifications);
  const unread = items.filter((n) => n.unread).length;
  return (
    <section className="flex h-[320px] w-[380px] max-w-full flex-col overflow-hidden rounded-card bg-surface shadow-card" aria-label="Inbox">
      <PageHeader
        size="pane"
        level={2}
        title="Inbox"
        description={unread ? `${unread} unread` : "All caught up"}
        actions={unread > 0 && <Button size="sm" variant="ghost" muted onClick={() => setItems(items.map((n) => ({ ...n, unread: false })))}>Mark all as read</Button>}
      />
      <ScrollArea className="min-h-0 flex-1" aria-label="Notifications">
        <ul className="flex flex-col">
          {items.map((n) => (
            <li key={n.id} className="flex items-start gap-2.5 border-b border-line-soft px-4 py-2.5 text-sm">
              <Avatar initials={n.initials} color={n.color} size="20" />
              <p className="min-w-0 flex-1 text-ink-2">
                <span className={n.unread ? "font-medium text-ink" : "text-ink-2"}>{n.who}</span> {n.what}
              </p>
              <span className="flex shrink-0 items-center gap-1.5 text-xs leading-5 text-ink-2">
                {n.when}
                {/* the dot keeps its place when read, so the times stay on one edge */}
                <span className={`size-1.5 rounded-full ${n.unread ? "bg-accent" : ""}`} aria-hidden />
                {n.unread && <span className="sr-only">Unread</span>}
              </span>
            </li>
          ))}
        </ul>
      </ScrollArea>
    </section>
  );
}
```

Vue · `inbox-pane.vue`

```vue
<script setup lang="ts">
import { computed, ref } from "vue";
import { Avatar } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { PageHeader } from "@/components/ui/page-header";
import { ScrollArea } from "@/components/ui/scroll-area";

const items = ref([
  { id: 1, who: "Priya Raman", initials: "PR", color: "var(--fndn-tag-purple)", what: "requested your review on #482 Add retry to webhook delivery", when: "2 min", unread: true },
  { id: 2, who: "Daniel Okafor", initials: "DO", color: "var(--fndn-tag-blue)", what: "assigned you NW-479 Usage alerts fire twice", when: "1 h", unread: true },
  { id: 3, who: "Aiko Tanaka", initials: "AT", color: "var(--fndn-tag-green)", what: "mentioned you in NW-471 Invoice PDF cuts the tax line", when: "3 h", unread: true },
  { id: 4, who: "Lucas Moreau", initials: "LM", color: "var(--fndn-tag-cyan)", what: "closed NW-466 Retry button stays disabled", when: "Nov 14", unread: false },
  { id: 5, who: "Sofia Alvarez", initials: "SA", color: "var(--fndn-tag-orange)", what: "commented on NW-458 Export usage as CSV", when: "Nov 12", unread: false },
]);
const unread = computed(() => items.value.filter((n) => n.unread).length);
const markAllRead = () => (items.value = items.value.map((n) => ({ ...n, unread: false })));
</script>

<!-- size="pane": the one-row header of a list in a pane, the count beside the title, its action at
     the end; the rows under it start on the title's 16px edge -->
<template>
  <section class="flex h-[320px] w-[380px] max-w-full flex-col overflow-hidden rounded-card bg-surface shadow-card" aria-label="Inbox">
    <PageHeader size="pane" :level="2" title="Inbox" :description="unread ? `${unread} unread` : 'All caught up'">
      <template v-if="unread > 0" #actions>
        <Button size="sm" variant="ghost" muted @click="markAllRead">Mark all as read</Button>
      </template>
    </PageHeader>
    <ScrollArea class="min-h-0 flex-1" aria-label="Notifications">
      <ul class="flex flex-col">
        <li v-for="n in items" :key="n.id" class="flex items-start gap-2.5 border-b border-line-soft px-4 py-2.5 text-sm">
          <Avatar :initials="n.initials" :color="n.color" size="20" />
          <p class="min-w-0 flex-1 text-ink-2">
            <span :class="n.unread ? 'font-medium text-ink' : 'text-ink-2'">{{ n.who }}</span> {{ n.what }}
          </p>
          <span class="flex shrink-0 items-center gap-1.5 text-xs leading-5 text-ink-2">
            {{ n.when }}
            <!-- the dot keeps its place when read, so the times stay on one edge -->
            <span :class="`size-1.5 rounded-full ${n.unread ? 'bg-accent' : ''}`" aria-hidden="true" />
            <span v-if="n.unread" class="sr-only">Unread</span>
          </span>
        </li>
      </ul>
    </ScrollArea>
  </section>
</template>
```

Svelte · `inbox-pane.svelte`

```svelte
<script lang="ts">
  import { Avatar } from "$lib/components/ui/avatar";
  import { Button } from "$lib/components/ui/button";
  import { PageHeader } from "$lib/components/ui/page-header";
  import { ScrollArea } from "$lib/components/ui/scroll-area";

  let items = $state([
    { id: 1, who: "Priya Raman", initials: "PR", color: "var(--fndn-tag-purple)", what: "requested your review on #482 Add retry to webhook delivery", when: "2 min", unread: true },
    { id: 2, who: "Daniel Okafor", initials: "DO", color: "var(--fndn-tag-blue)", what: "assigned you NW-479 Usage alerts fire twice", when: "1 h", unread: true },
    { id: 3, who: "Aiko Tanaka", initials: "AT", color: "var(--fndn-tag-green)", what: "mentioned you in NW-471 Invoice PDF cuts the tax line", when: "3 h", unread: true },
    { id: 4, who: "Lucas Moreau", initials: "LM", color: "var(--fndn-tag-cyan)", what: "closed NW-466 Retry button stays disabled", when: "Nov 14", unread: false },
    { id: 5, who: "Sofia Alvarez", initials: "SA", color: "var(--fndn-tag-orange)", what: "commented on NW-458 Export usage as CSV", when: "Nov 12", unread: false },
  ]);
  const unread = $derived(items.filter((n) => n.unread).length);
</script>

<!-- size="pane": the one-row header of a list in a pane, the count beside the title, its action at
     the end; the rows under it start on the title's 16px edge -->
{#snippet markAllRead()}
  <Button size="sm" variant="ghost" muted onclick={() => (items = items.map((n) => ({ ...n, unread: false })))}>Mark all as read</Button>
{/snippet}
<section class="flex h-[320px] w-[380px] max-w-full flex-col overflow-hidden rounded-card bg-surface shadow-card" aria-label="Inbox">
  <PageHeader size="pane" level={2} title="Inbox" description={unread ? `${unread} unread` : "All caught up"} actions={unread > 0 ? markAllRead : undefined} />
  <ScrollArea class="min-h-0 flex-1" aria-label="Notifications">
    <ul class="flex flex-col">
      {#each items as n (n.id)}
        <li class="flex items-start gap-2.5 border-b border-line-soft px-4 py-2.5 text-sm">
          <Avatar initials={n.initials} color={n.color} size="20" />
          <p class="min-w-0 flex-1 text-ink-2">
            <span class={n.unread ? "font-medium text-ink" : "text-ink-2"}>{n.who}</span> {n.what}
          </p>
          <span class="flex shrink-0 items-center gap-1.5 text-xs leading-5 text-ink-2">
            {n.when}
            <!-- the dot keeps its place when read, so the times stay on one edge -->
            <span class="size-1.5 rounded-full {n.unread ? 'bg-accent' : ''}" aria-hidden="true"></span>
            {#if n.unread}<span class="sr-only">Unread</span>{/if}
          </span>
        </li>
      {/each}
    </ul>
  </ScrollArea>
</section>
```

### At phone width, the actions go under the title

React · `billing-on-a-phone.tsx`

```tsx
import { DownloadSimple } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { PageHeader } from "@/components/ui/page-header";
import { TextRow } from "@/components/ui/text-row";

const usage = [
  { label: "Seats", value: "12", meta: "of 20" },
  { label: "Build minutes", value: "4,120", meta: "of 6,000" },
  { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
];

/* at phone width the title keeps its line: when the actions do not fit beside 10rem of text they
 * drop under it, at its start, and nothing is cut */
export default function BillingOnAPhone() {
  return (
    <div className="flex w-[358px] max-w-full flex-col gap-6">
      <PageHeader
        title="Billing"
        description="Invoices go to maya@northwind.example on the 1st."
        back={{ label: "Settings", href: "/settings" }}
        actions={
          <>
            <Button size="sm" icon={<DownloadSimple data-slot="icon" weight="bold" />}>Invoices</Button>
            <Button size="sm">Payment method</Button>
          </>
        }
      />
      <Card>
        <CardHeader>
          <div>
            <CardTitle>Team plan</CardTitle>
            <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
          </div>
        </CardHeader>
        <CardBody>
          {usage.map((row) => (
            <TextRow key={row.label} label={row.label} value={row.value} meta={row.meta} />
          ))}
        </CardBody>
        <CardFooter>
          <Button variant="primary" size="sm">Upgrade to Business</Button>
        </CardFooter>
      </Card>
    </div>
  );
}
```

Vue · `billing-on-a-phone.vue`

```vue
<script setup lang="ts">
import { PhDownloadSimple } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { PageHeader } from "@/components/ui/page-header";
import { TextRow } from "@/components/ui/text-row";

const usage = [
  { label: "Seats", value: "12", meta: "of 20" },
  { label: "Build minutes", value: "4,120", meta: "of 6,000" },
  { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
];
</script>

<!-- at phone width the title keeps its line: when the actions do not fit beside 10rem of text they
     drop under it, at its start, and nothing is cut -->
<template>
  <div class="flex w-[358px] max-w-full flex-col gap-6">
    <PageHeader title="Billing" description="Invoices go to maya@northwind.example on the 1st." :back="{ label: 'Settings', href: '/settings' }">
      <template #actions>
        <Button size="sm">
          <template #icon><PhDownloadSimple data-slot="icon" weight="bold" /></template>
          Invoices
        </Button>
        <Button size="sm">Payment method</Button>
      </template>
    </PageHeader>
    <Card>
      <CardHeader>
        <div>
          <CardTitle>Team plan</CardTitle>
          <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
        </div>
      </CardHeader>
      <CardBody>
        <TextRow v-for="row in usage" :key="row.label" :label="row.label" :value="row.value" :meta="row.meta" />
      </CardBody>
      <CardFooter>
        <Button variant="primary" size="sm">Upgrade to Business</Button>
      </CardFooter>
    </Card>
  </div>
</template>
```

Svelte · `billing-on-a-phone.svelte`

```svelte
<script lang="ts">
  import DownloadSimple from "phosphor-svelte/lib/DownloadSimpleIcon";
  import { Button } from "$lib/components/ui/button";
  import { Card, CardBody, CardDescription, CardFooter, CardHeader, CardTitle } from "$lib/components/ui/card";
  import { PageHeader } from "$lib/components/ui/page-header";
  import { TextRow } from "$lib/components/ui/text-row";

  const usage = [
    { label: "Seats", value: "12", meta: "of 20" },
    { label: "Build minutes", value: "4,120", meta: "of 6,000" },
    { label: "Bandwidth", value: "182 GB", meta: "of 1 TB" },
  ];
</script>

<!-- at phone width the title keeps its line: when the actions do not fit beside 10rem of text they
     drop under it, at its start, and nothing is cut -->
<div class="flex w-[358px] max-w-full flex-col gap-6">
  <PageHeader title="Billing" description="Invoices go to maya@northwind.example on the 1st." back={{ label: "Settings", href: "/settings" }}>
    {#snippet actions()}
      <Button size="sm">
        {#snippet icon()}<DownloadSimple data-slot="icon" weight="bold" />{/snippet}
        Invoices
      </Button>
      <Button size="sm">Payment method</Button>
    {/snippet}
  </PageHeader>
  <Card>
    <CardHeader>
      <div>
        <CardTitle>Team plan</CardTitle>
        <CardDescription>$240.00 a month · renews Dec 1, 2026</CardDescription>
      </div>
    </CardHeader>
    <CardBody>
      {#each usage as row (row.label)}
        <TextRow label={row.label} value={row.value} meta={row.meta} />
      {/each}
    </CardBody>
    <CardFooter>
      <Button variant="primary" size="sm">Upgrade to Business</Button>
    </CardFooter>
  </Card>
</div>
```

## Recipe

`page-header.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";
import { link } from "../link/link.recipe";

/* page-header — the strip at the top of a screen's content: a back link, a title, a description,
 * and the actions at the end of the title's line.
 *
 *   page  (default) the title of a page: 20px/600 ink on a 28px line, the description 13px ink-2
 *         under it, the back link 13px ink-2 above it. No padding and no edge of its own: it sits
 *         in the page's content column, which gives the inset and the gap to what follows.
 *   pane  the header row of a pane above a list (an inbox, a panel): one row at least 44px tall,
 *         16px in at both ends, a hairline (line) under it; the title 13px/600 with the
 *         description 12px ink-2 beside it on the same line, the back link before them on the
 *         title's first line (baseline), the lines centred in the row.
 *
 * Wrapping: nothing is cut. The title and the description wrap (anywhere, so an unbroken name
 * never overflows). The text keeps at least 10rem beside the actions (8rem in a pane, whose 13px
 * title is short: "Inbox  3 unread" and its action stay on one row at phone width); when the
 * actions do not fit beside that, they drop to their own line under the text, at its start, and
 * wrap among themselves. On a phone a page's two actions usually drop: the description then keeps
 * the full width instead of wrapping in a narrow column beside them. The actions sit on the title's first line: sm Buttons are 28px, the title's line is
 * 28px (page), and a pane's row centres them.
 *
 * The back link is the Link recipe (standalone, neutral) on an <a> or a <button>: 13px ink-2, ink
 * and underlined on hover, a taller hit area on touch; its arrow mirrors right-to-left. Author
 * text keeps its own direction ([unicode-bidi:plaintext]) and its alignment on the page's side.
 * Static: nothing moves but the link's colour. */

const backLink = link({ variant: "standalone", tone: "neutral" });
const SIDE = "[&:dir(ltr)]:text-left [&:dir(rtl)]:text-right";

export const pageHeader = tv({
  slots: {
    base: "flex min-w-0",
    back: [
      backLink.base(),
      "self-start font-normal text-sm leading-5 text-ink-2 hover:text-ink active:text-ink",
      /* the arrow sits at the page's start whatever the label's own script: the link's plaintext
       * would lay a Latin label out left to right in a right-to-left page, the arrow on its left */
      "[unicode-bidi:isolate]",
      "[&>[data-slot=icon]]:size-3.5 [&>[data-slot=icon]]:me-1 [&>[data-slot=icon]]:align-[-2px]",
      "[&:dir(rtl)>[data-slot=icon]]:[transform:scaleX(-1)]",
    ],
    row: "flex min-w-0 flex-wrap gap-x-4",
    text: "flex min-w-0",
    title: ["m-0 font-semibold text-ink wrap-anywhere [unicode-bidi:plaintext]", SIDE],
    description: ["m-0 text-ink-2 wrap-anywhere [unicode-bidi:plaintext]", SIDE],
    actions: "flex min-w-0 max-w-full flex-wrap items-center gap-2",
  },
  variants: {
    size: {
      page: {
        base: "flex-col gap-1",
        row: "items-start gap-y-3",
        text: "flex-[1_1_10rem] flex-col gap-1",
        title: "text-xl leading-7",
        description: "text-sm leading-5",
      },
      pane: {
        base: "flex-row flex-wrap content-center items-baseline gap-x-3 gap-y-1 min-h-11 px-4 py-2 border-b border-line",
        back: "self-baseline",
        row: "flex-1 items-center gap-y-2",
        text: "flex-[1_1_8rem] flex-row flex-wrap items-baseline gap-x-2",
        title: "text-sm leading-5",
        description: "text-xs leading-5",
      },
    },
  },
  defaultVariants: { size: "page" },
});

export type PageHeaderRecipeProps = VariantProps<typeof pageHeader>;
```
