# Panel Header

The header of a layered panel, drawer, sheet or dialog: a 40 px icon tile, a 16 px title with a muted line under it, a round close button, 16 / 24 padding and a rule underneath.

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

```tsx
import { PanelHeader } from "@leap-crm/design-system";
```

## Best practices

- Do: Use it at the top of a layered panel or sheet you build yourself, and pass `onClose` so there is a visible way out besides Escape.
- Do: Pass `titleId` and point the panel's `aria-labelledby` at it, so a screen reader names the panel by its title.
- Do: Set `closeLabel` when panels stack, like "Close contact" over an opportunity, so each close button has a unique name.
- Don't: Use it in a `Drawer` or `Dialog`. Use `DrawerHeader` or `DialogHeader`, which wire the title and close button to the popup itself.
- Don't: Use it to head a section inside the panel. Use `SectionHeader`, a step down in size, so the panel's own title stays the strongest.

## Keyboard

| Keys | What they do |
| --- | --- |
| Enter, Space | Close the panel, with focus on its close button. |

## Related

- [Section Header](./section-header.md)
- [Drawer](./drawer.md)
- [Close Button](./close-button.md)
- [Step Header](./step-header.md)

## Examples

What the examples import:

```tsx
import { Folder, UserPlus } from "lucide-react";
import { PanelHeader } from "@leap-crm/design-system";
```

### Full

```tsx
<PanelHeader
  className="w-160"
  icon={<UserPlus />}
  title="Create contact"
  subtitle="Add a person to your firm’s contacts."
  onClose={() => undefined}
/>
```

### Any tone, no subtitle

```tsx
<PanelHeader
  className="w-160"
  icon={<Folder />}
  tone="success"
  title="Documents"
  onClose={() => undefined}
  closeLabel="Close documents"
/>
```

### Without a close

Leave out onClose when the panel closes some other way.

```tsx
<PanelHeader
  className="w-160"
  title="Matter details"
  subtitle="Conveyancing · Purchase"
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` | `ReactNode` |  | The 20 px icon in the 40 px tile on the left. |
| `tone` | `Exclude<Tone, "default" \| "plum"> \| "neutral"` | `"info"` | The icon tile's colour, as IconTile. |
| `title` (required) | `ReactNode` |  | The panel's name. |
| `subtitle` | `ReactNode` |  | One muted line straight under the title. |
| `onClose` | `() => void` |  | Shows the round close button and runs when it's pressed. |
| `closeLabel` | `string` | `"Close"` | Names the close button when "Close" isn't enough. |
| `titleId` | `string` |  | An id for the title, so a dialog or drawer can name itself with aria-labelledby. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
