---
title: "Dialog"
description: "A window over the page for one task, such as a short form or a detail view. The page behind waits until people close it."
url: https://gelatinui.com/components/dialog
markdown_url: https://gelatinui.com/components/dialog.md
access: free
install: "npx shadcn@latest add @gelatin-ui/dialog"
registry_item: https://gelatinui.com/r/dialog.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Dialog

> A window over the page for one task, such as a short form or a detail view. The page behind waits until people close it.

Page: https://gelatinui.com/components/dialog

## When to use it

Best for: One focused task over the page: a short form, a detail view, or a setting.

- Use it for one task that needs the full attention of the user.
- Always render a `DialogTitle`.
- Put the Cancel (`DialogClose`) first in the footer and the main action last.

## When not to use it

- For a yes or no question before a destructive action, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).

## Notes for agents

- Always render a `DialogTitle`: it names the dialog for screen readers.
- Put `DialogClose` (Cancel) first in the footer and the main action last.

## Anatomy

```text
Dialog
├─ DialogTrigger (0..n)
├─ DialogPortal (0..n)
├─ DialogOverlay (0..n)
├─ DialogContent (0..n)
├─ DialogHeader (0..n)
├─ DialogTitle (0..n)
├─ DialogDescription (0..n)
├─ DialogBody (0..n)
├─ DialogFooter (0..n)
└─ DialogClose (0..n)
```

## API reference

### Dialog

Also takes every prop of Base UI `Dialog.Root`: https://base-ui.com/react/components/dialog

### DialogTrigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Dialog.Trigger`: https://base-ui.com/react/components/dialog

### DialogPortal

Also takes every prop of Base UI `Dialog.Portal`: https://base-ui.com/react/components/dialog

### DialogOverlay

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

Also takes every prop of Base UI `Dialog.Backdrop`: https://base-ui.com/react/components/dialog

### DialogContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `scroll` | `"inside" \| "outside"` |  |  |
| `size` | `"default" \| "lg" \| "sm" \| "xl"` |  |  |
| `className` | `string` |  |  |
| `backdrop` | `boolean` | true | Dim the page under the dialog (Base UI `Dialog.Backdrop`). Default `true`. |
| `showCloseButton` | `boolean` | true | Show the close button (a 24px ghost icon button) in the top end corner. Default `true`. |
| `closeLabel` | `string` | "Close" | The accessible name of the close button. Translate it with the page. |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `backdropProps` | `DialogOverlayProps` |  |  |
| `viewportProps` | `PopupPartProps` |  |  |
| `closeButtonProps` | `PopupPartProps` |  |  |

Also takes every prop of Base UI `Dialog.Popup`: https://base-ui.com/react/components/dialog

### DialogHeader

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DialogTitle

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### DialogDescription

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

### DialogBody

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DialogFooter

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### DialogClose

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| DialogTrigger | `dialog-trigger` | `data-disabled` |  |  |
| DialogPortal | `dialog-portal` |  |  |  |
| DialogOverlay | `dialog-overlay` |  |  |  |
| DialogContent | `dialog-content` |  |  |  |
| DialogHeader | `dialog-header` |  |  |  |
| DialogTitle | `dialog-title` |  |  |  |
| DialogDescription | `dialog-description` |  |  |  |
| DialogBody | `dialog-body` |  |  |  |
| DialogFooter | `dialog-footer` |  |  |  |
| DialogClose | `dialog-close` | `data-disabled` |  |  |

## Usage

Always render a `DialogTitle`: it gives the dialog its name. Render the trigger and the close buttons as a Button through `render`.

The sample also uses `button`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/dialog @gelatin-ui/button
```

```tsx title="release-notes-dialog.tsx"
import { Button } from "@/components/ui/button";
import { Dialog, DialogBody, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";

export function ReleaseNotesDialog() {
  return (
    <Dialog>
      <DialogTrigger render={<Button variant="outline" />}>What is new</DialogTrigger>
      <DialogContent size="lg" scroll="inside" closeLabel="Close">
        <DialogHeader>
          <DialogTitle>What is new in Northwind</DialogTitle>
        </DialogHeader>
        <DialogBody>Projects have a timeline view. Drag a task to change its dates.</DialogBody>
        <DialogFooter>
          <DialogClose render={<Button />}>Got it</DialogClose>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
```

## Compose

Build it with:

- [Form](https://gelatinui.com/components/form.md): Owns the submit and the errors.
- [Field](https://gelatinui.com/components/field.md): Names each control and shows its error text.
- [Input](https://gelatinui.com/components/input.md): Takes short text.
- [Textarea](https://gelatinui.com/components/textarea.md): Takes long text.
- [Stepper](https://gelatinui.com/components/stepper.md): Shows the steps of a long form.
- [Button](https://gelatinui.com/components/button.md): Submits or moves to the next step.
- [Alert](https://gelatinui.com/components/alert.md): Shows an error of the whole form.

Rules:

- Sheets on phones (`phone-sheets`): Show a dialog or a large popover as a bottom sheet on a small screen.
- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Labels real apps use (`real-labels`): Write the button and menu labels that real apps use ("Create API key", "Invite members"), with no "…" at the end.
- No layout jump (`no-layout-jump`): When a state change adds, removes, or resizes content, reserve its space or animate its size, so nothing below it jumps.

Patterns: `gelatin://patterns/form-flow`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/dialog
```

It adds 17 registry items: 14 files, 2562 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md): Pick Alert Dialog for one yes or no question before a destructive or blocking action, not for a form or a task.
- [Button](https://gelatinui.com/components/button.md)
- [Form](https://gelatinui.com/components/form.md)
- [Drawer](https://gelatinui.com/components/drawer.md): Pick Drawer for a panel that slides in from an edge and follows the finger, such as a side panel or a phone sheet.
- [Popover](https://gelatinui.com/components/popover.md): Pick Popover for a small panel next to its button that does not block the rest of the page.

## Keyboard

| Keys | Action |
| --- | --- |
| Esc | Closes the dialog. |
| Tab | Moves the focus to the next element. The focus stays in the dialog. |
| Shift Tab | Moves the focus to the previous element. |

## Accessibility

The window is a Base UI `Dialog.Popup`. `DialogTitle` is an `h2` that names it (`aria-labelledby`), and `DialogDescription` describes it (`aria-describedby`). A screen reader reads both when the dialog opens.

The dialog is modal by default: the focus moves into it and stays in it until it closes. `modal` also takes `false` or `"trap-focus"`. With `scroll="outside"`, the popup itself gets the first focus.

The close button in the top end corner is a 24px ghost icon Button. Its name comes from `closeLabel` (default "Close"): translate it with the page. Each Button grows to a 44px touch target on a touch screen (`hit-area`).

When `DialogBody` scrolls and holds only text, give it `tabIndex={0}` and an `aria-label`, so a keyboard user can scroll it.

## Motion

| Part | Motion |
| --- | --- |
| Open | overlay · 200ms · ease-panel (0.2, 0.4, 0.2, 1) · the panel fades in and scales from 95%, the backdrop fades in |
| Close | overlay-exit · 150ms · ease-out (0, 0, 0.2, 1) · the panel fades out and scales to 95%, the backdrop fades out |
| Child dialog opens | overlay · 200ms · ease-panel (0.2, 0.4, 0.2, 1) · the parent panel moves back 4% and up 8px |
