# Modal

A dialog, side sheet or full-screen panel for a focused task.

- **Use it for**: A focused task that blocks the page until done or dismissed.
- **Not for**: Information people need while still using the page. Try [Sidecar](https://unseenui.com/components/sidecar/), [Popover](https://unseenui.com/components/popover/).

## Installation

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

## Usage

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

<Modal layout="dialog" open={open} onOpenChange={setOpen} title="Project details" description="Review the selected project." trigger={<Button>Open details</Button>} footer={<Button onClick={() => setOpen(false)}>Done</Button>}>{content}</Modal>
```

## Props

- `open` (`boolean`): Whether the panel is open.
- `onOpenChange` (`(open: boolean) => void`): Update open when the trigger, close button or dismissal changes it.
- `title` (`string`): The accessible panel name. Also shown as the heading unless you supply header.
- `description` (`string`): A short task explanation. It remains visible below the default or custom heading.
- `trigger` (`ReactNode`): One trigger element that accepts button props and a ref.
- `children` (`ReactNode`): Your content in the scrollable body.
- `layout` (`'dialog' | 'sheet' | 'fullscreen' (optional)`): Choose the panel presentation. Defaults to dialog.
- `header` (`ReactNode (optional)`): Replaces the visible title. The title prop still supplies the accessible name.
- `footer` (`ReactNode (optional)`): Your actions below the scrolling body. Set open to false from a cancel handler.
- `className` (`string (optional)`): Adds a class to the panel surface in every layout.
- `style` (`CSSProperties (optional)`): Inline styles for the panel surface, such as a custom width.

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `children` (required) | `ReactNode` |  |
| `className` | `string` | Applied to the dialog surface, including sheet and fullscreen layouts. |
| `description` (required) | `string` |  |
| `footer` | `ReactNode` | Host-owned actions, kept outside the scrolling body. |
| `header` | `ReactNode` | Replaces the visible heading; title still supplies the accessible dialog name. |
| `layout` | `"dialog" \| "sheet" \| "fullscreen"` |  |
| `onOpenChange` (required) | `(open: boolean) => void` |  |
| `open` (required) | `boolean` |  |
| `style` | `CSSProperties` |  |
| `title` (required) | `string` |  |
| `trigger` | `ReactNode` |  |

## Keyboard

Opening moves focus into the dialog. Tab remains inside; Escape closes it and returns focus to the trigger. The title and description name the task.

## Works with

[Popover](https://unseenui.com/components/popover/), [Tooltip](https://unseenui.com/components/tooltip/), [ShortcutHelp](https://unseenui.com/components/shortcut-help/), [AlertDialog](https://unseenui.com/components/alert-dialog/)

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