# App Header

The CRM's 48 px navy bar: page links on the left, round actions and the user on the right. On navy, keyboard focus is the light halo alone. Notification rows fill the bell's list.

- Beta: ready to use; its API can still change in a minor release.
- Category: Navigation

```tsx
import { AppHeader, HeaderNavLink, HeaderIconButton, NotificationRow } from "@leap-crm/design-system";
```

## Best practices

- Do: Use `AppHeader` once, at the top of the app, with a `HeaderNavLink` for each main page and `HeaderIconButton`s and the user's avatar in `actions`.
- Do: Pass your router's link as each `HeaderNavLink`'s `render`, and set `active` on the page you're on so it is marked with `aria-current`.
- Do: Give every `HeaderIconButton` an `aria-label`, like "Notifications", and set `open` while its popover or menu is open so it shows orange.
- Do: Pass unread items as `count`. It hides at 0, caps at 99+, and screen readers hear it as part of the button's name.
- Don't: Put a library `Button` or `IconButton` on the navy bar. Use `HeaderIconButton`, which takes the chrome text colour and shows focus as the halo alone, as navy needs.
- Don't: Mark a notification read by colour alone. Set `read` on its `NotificationRow`; screen readers hear "Unread" before every title that isn't.

## Keyboard

| Keys | What they do |
| --- | --- |
| Tab | Moves through the links and buttons in order. |
| Enter | Follows the focused link. |
| Enter, Space | Presses the focused button. |

## Related

- [Tabs](./tabs.md)
- [Breadcrumbs](./breadcrumbs.md)
- [Panel Header](./panel-header.md)

## Examples

What the examples import:

```tsx
import { Bell, BookUser, ChartLine, LayoutDashboard, Plus, Search, Sprout, SquareCheckBig, UserPlus } from "lucide-react";
import { useState } from "react";
import { AppHeader, Avatar, HeaderIconButton, HeaderNavLink, NotificationRow } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const pages = [
  { label: "Dashboard", icon: <LayoutDashboard /> },
  { label: "Opportunities", icon: <Sprout /> },
  { label: "Contacts", icon: <BookUser /> },
  { label: "Insights", icon: <ChartLine /> },
];

function Header() {
  const [page, setPage] = useState("Opportunities");
  const [open, setOpen] = useState(false);
  return (
    <AppHeader
      className="w-full"
      nav={pages.map(item => (
        <HeaderNavLink
          key={item.label}
          href="/app-header"
          icon={item.icon}
          active={page === item.label}
          onClick={event => {
            event.preventDefault();
            setPage(item.label);
          }}
        >
          {item.label}
        </HeaderNavLink>
      ))}
      actions={
        <>
          <HeaderIconButton icon={<Plus />} aria-label="New" />
          <HeaderIconButton icon={<Search />} aria-label="Search" />
          <HeaderIconButton
            icon={<Bell />}
            aria-label="Notifications"
            count={3}
            open={open}
            onClick={() => setOpen(value => !value)}
          />
          <Avatar size="lg" person="staff" name="Jane Citizen" initials="JC" />
        </>
      }
    />
  );
}
```

### Header

Press a page to move the orange underline; hover for orange; Tab for the inset halo. The bell carries a red count and turns orange while its list is open (press it).

```tsx
<Header />
```

### Icon buttons

32 px, the raised chrome tone at rest (navy-400 in light mode), a step lighter on hover, brand orange while open. The count hides at 0 and caps at 99+; screen readers hear it in the name.

```tsx
<div className="bg-chrome flex items-center gap-3 rounded-md p-3">
  <HeaderIconButton icon={<Plus />} aria-label="New" />
  <HeaderIconButton icon={<UserPlus />} aria-label="New contact" open />
  <HeaderIconButton
    icon={<Bell />}
    aria-label="Notifications"
    count={3}
  />
  <HeaderIconButton
    icon={<Bell />}
    aria-label="Notifications"
    count={128}
  />
</div>
```

### Notification rows

Unread: dark title at 450 on white. Read: muted at 400 on the subtle fill. Hover or keyboard focus shows the muted highlight, never a ring.

```tsx
<div className="border-neutral-border flex w-112 flex-col rounded-md border">
  <NotificationRow
    icon={<SquareCheckBig />}
    title="You were assigned a task"
    meta="Call the vendor's solicitor · Due tomorrow"
    time="2m"
  />
  <NotificationRow
    icon={<SquareCheckBig />}
    title="Settlement booked for 14 December"
    meta="Hartley Okafor Moreau Family Trust (Superannuation Fund No. 2) · Conveyancing"
    time="1h"
    read
  />
</div>
```

## Props

### AppHeader

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `nav` (required) | `ReactNode` |  | The main navigation: HeaderNavLinks. |
| `actions` | `ReactNode` |  | The actions on the right: HeaderIconButtons and the user's avatar. |
| `navLabel` | `string` | `"Main"` | Names the navigation for screen readers. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### HeaderNavLink

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` (required) | `ReactNode` |  | A 16 px icon before the label. |
| `children` (required) | `string` |  | What it shows inside. |
| `active` | `boolean` | `false` | The page you're on: orange at 600, with the 3 px underline. |
| `render` | `ReactElement<{ className?: string; children?: ReactNode }>` |  | Your router's link, like <Link to="/contacts" />. Defaults to an <a>. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### HeaderIconButton

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` (required) | `ReactNode` |  | The 16 px icon it shows. Name the button with aria-label. |
| `aria-label` (required) | `string` |  | An icon-only button has no visible text, so its name is required. |
| `count` | `number` | `0` | Unread or waiting items, as a red count in the corner. Hidden at 0. |
| `open` | `boolean` | `false` | Its popover or menu is open: brand orange. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### NotificationRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` (required) | `ReactNode` |  | A 16 px icon for what happened, like a checked square for a task. |
| `title` (required) | `string` |  | What happened, in a line, like "Ada assigned you a task". |
| `meta` | `string` |  | The detail line, like "Call the vendor's solicitor · Due tomorrow". |
| `time` (required) | `string` |  | How long ago, already worded, like "2m". |
| `read` | `boolean` | `false` | Read notifications sit on the subtle surface with a muted, regular-weight title; unread ones are announced as Unread. |
| `onSelect` | `() => void` |  | Opens what it's about. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
