# Sidecar

A drawer, sheet or inspector panel: docked beside content, floating over it, and a modal drawer or bottom sheet on small screens.

- **Use it for**: An inspector or drawer beside content, becoming a sheet on small screens.
- **Not for**: Blocking tasks. Try [Modal](https://unseenui.com/components/modal/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { Sidecar } from '@stackunseen/ui/sidecar';
import { Button } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Sidecar presentation="docked" open={open} onOpenChange={setOpen} title="Document details" trigger={<Button>Inspect document</Button>}>{details}</Sidecar>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `actions` | `ReactNode` | Compact contextual actions. |
| `bodyLabel` | `string` |  |
| `children` (required) | `ReactNode` |  |
| `closeLabel` | `string` |  |
| `closeOnEscape` | `boolean` | Overlay only: close on Escape wherever focus is while this is the most recently opened layer (default true). |
| `description` | `string` |  |
| `dismissOnInteractOutside` | `boolean` | Drawer pointer dismissal (default true). |
| `footer` | `ReactNode` |  |
| `headingLevel` | `3 \| 2 \| 4 \| 5 \| 6` |  |
| `initialFocusRef` | `RefObject<HTMLElement \| null>` | Optional initial target inside the panel; otherwise drawers focus the panel. |
| `inset` | `number \| { top?: number; bottom?: number; inline?: number; }` | Overlay only: distance from the viewport edges in pixels, for example to clear a sticky site header. |
| `mobileBreakpoint` | `number \| false` | Docked and overlay panels change presentation at this viewport width. |
| `narrowPresentation` | `SidecarNarrowPresentation` | Below the breakpoint a docked or overlay panel becomes a modal drawer, or with `sheet` a non-modal bottom sheet (--ai-sidecar-sheet-height, 46vh) that leaves the content above it visible and scrollable: the page body is padded by the sheet… |
| `onEscapeKeyDown` | `((event: KeyboardEvent) => void)` |  |
| `onOpenChange` (required) | `(open: boolean) => void` |  |
| `open` (required) | `boolean` | Visibility belongs to the host. |
| `presentation` | `SidecarPresentation` |  |
| `returnFocusRef` | `RefObject<HTMLElement \| null>` | Used when the opener is outside this component or is replaced by host state. |
| `side` | `"end" \| "start"` |  |
| `title` (required) | `string` |  |
| `toolbar` | `ReactNode` |  |
| `trigger` | `ReactElement<unknown, string \| JSXElementConstructor<any>>` | A single focusable element, such as the shared Button or IconButton. |

## Keyboard

The trigger opens the inspector. Modal drawers contain focus and Escape returns it to the opener. An overlay inspector takes focus when it opens and closes on Escape from anywhere; docked panels allow working elsewhere.

## Works with

[SplitPane](https://unseenui.com/components/split-pane/), [WorkspaceShell](https://unseenui.com/components/workspace-shell/)

Page: https://unseenui.com/components/sidecar/
