---
title: "Dialog Stack"
description: "Dialogs that open on top of each other for a task with steps. The dialog below steps back, and Back or Escape returns one level."
url: https://gelatinui.com/components/dialog-stack
markdown_url: https://gelatinui.com/components/dialog-stack.md
access: free
install: "npx shadcn@latest add @gelatin-ui/dialog-stack"
registry_item: https://gelatinui.com/r/dialog-stack.json
version: "2026-11-17"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Dialog Stack

> Dialogs that open on top of each other for a task with steps. The dialog below steps back, and Back or Escape returns one level.

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

## When to use it

Best for: A short task that starts in a dialog and needs one or two more dialogs on top, with a way back.

- Use it when a step needs its own dialog and the person must come back to the dialog below.
- Use `DialogStackGuard` on a level with a form, so Back, Escape, or the scrim asks first.
- Keep the stack to two or three levels. Past three, only the top three show.

## When not to use it

- For one dialog with no level on top, use a [Dialog](https://gelatinui.com/components/dialog.md).
- For a single yes or no question, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).
- For a panel from the edge of the screen, use a [Drawer](https://gelatinui.com/components/drawer.md).

## Notes for agents

- Nest each `DialogStackLevel` inside the `DialogStackContent` of the level below. Every level needs a short `label`: the path shows it.
- Put `DialogStackNav` with `DialogStackBack`, `DialogStackPath`, and `DialogStackShortcut` at the top of each upper level.
- A level is never wider than the level below: a wider `size` on top falls back to the size below.
- A press on the scrim closes the whole stack. A press on a level below closes only the top level.
- A close from code (`actionsRef`, a controlled `open`) never asks the guard.
- Under 640px each level is a sheet on the bottom edge.

## Anatomy

```text
DialogStack
├─ DialogStackTrigger (0..n)
├─ DialogStackContent (0..n)
├─ DialogStackNav (0..n)
├─ DialogStackBack (0..n)
├─ DialogStackPath (0..n)
├─ DialogStackShortcut (0..n)
├─ DialogStackDepth (0..n)
├─ DialogStackGuard (0..n)
└─ DialogStackGuardDiscard (0..n)
```

## API reference

### DialogStack

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `labels` | `Partial<DialogStackLabels>` |  | The words the stack writes itself (the depth line, the folded chip, the Back name). |
| `children` | `ReactNode` |  |  |

### DialogStackLevel

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` |  | The short name of this level in the path of the levels above it ("Remove member"). |
| `size` | `"default" \| "lg" \| "sm" \| "xl"` | "default" | The width of the level (the Dialog sizes). A level is never wider than the level below it, so a wider size on top falls back to the size below. Default `default` (448px). |

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

### DialogStackTrigger

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

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

### DialogStackContent

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

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

### DialogStackNav

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

### DialogStackBack

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "outline" |  |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### DialogStackPath

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

### DialogStackShortcut

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg"` |  |  |
| `variant` | `"default" \| "ghost"` |  |  |

### DialogStackDepth

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

### DialogStackGuard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `portalProps` | `Omit` |  | Other Base UI props of the inner parts. A `className` here adds to the component classes. |
| `backdropProps` | `AlertDialogOverlayProps` |  |  |
| `viewportProps` | `PopupPartProps` |  |  |
| `size` | `"default" \| "sm"` | "sm" |  |
| `when` | `boolean` |  | The level has unsaved changes: every close by the person asks first. |
| `children` | `ReactNode` |  | The question. Default: "Discard your changes?" with Keep editing and Discard. |

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

### DialogStackGuardDiscard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `glass` | `"clear" \| "dark" \| "light"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |
| `size` | `"default" \| "icon" \| "icon-lg" \| "icon-sm" \| "icon-xs" \| "lg" \| "sm" \| "xl" \| "xs"` |  |  |
| `variant` | `"dashed" \| "default" \| "destructive" \| "destructive-outline" \| "ghost" \| "link" \| "media" \| "outline" \| "secondary"` | "destructive" |  |
| `className` | `string` |  |  |
| `busy` | `boolean` |  | The button waits for the app (busy words): a spinner, `aria-busy`, and no clicks. Focus stays on the button. The style hook stays `data-loading`. |
| `spinnerPlacement` | `"center" \| "start"` |  | `center` (default): the spinner covers the label. `start`: it takes the leading icon slot. The icon sizes always use `center`, because their one icon is the label. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| DialogStackTrigger | `dialog-stack-trigger` |  |  |  |
| DialogStackContent | `dialog-stack-content` | `data-folded`, `data-nested-dialog-open` |  | `motion-timing` |
| DialogStackNav | `dialog-stack-nav` |  |  |  |
| DialogStackBack | `dialog-stack-back` |  |  |  |
| DialogStackPath | `dialog-stack-path` |  |  |  |
| DialogStackShortcut | `dialog-stack-shortcut` |  |  |  |
| DialogStackDepth | `dialog-stack-depth` |  |  |  |
| DialogStackGuard | `dialog-stack-guard` |  |  |  |
| DialogStackGuardDiscard | `dialog-stack-guard-discard` |  |  |  |

## Usage

Nest each `DialogStackLevel` inside the content of the level below it.

```tsx title="workspace-settings.tsx"
import { Button } from "@/components/ui/button";
import { DialogClose, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import {
  DialogStack,
  DialogStackBack,
  DialogStackContent,
  DialogStackDepth,
  DialogStackLevel,
  DialogStackNav,
  DialogStackPath,
  DialogStackShortcut,
  DialogStackTrigger,
} from "@/components/ui/dialog-stack";

export function WorkspaceSettings() {
  return (
    <DialogStack>
      <DialogStackLevel label="Workspace settings">
        <DialogStackTrigger render={<Button variant="outline" />}>Settings</DialogStackTrigger>
        <DialogStackContent>
          <DialogHeader><DialogTitle>Workspace settings</DialogTitle></DialogHeader>
          <DialogStackLevel label="Remove member">
            <DialogStackTrigger render={<Button variant="destructive" />}>Remove Marco</DialogStackTrigger>
            <DialogStackContent>
              <DialogStackNav><DialogStackBack /><DialogStackPath /><DialogStackShortcut /></DialogStackNav>
              <DialogHeader><DialogTitle>Remove Marco Rossi?</DialogTitle></DialogHeader>
              <DialogFooter>
                <DialogStackDepth />
                <DialogClose render={<Button variant="destructive" />}>Remove member</DialogClose>
              </DialogFooter>
            </DialogStackContent>
          </DialogStackLevel>
        </DialogStackContent>
      </DialogStackLevel>
    </DialogStack>
  );
}
```

## Compose

Rules:

- Sheets on phones (`phone-sheets`): Show a dialog or a large popover as a bottom sheet on a small screen.
- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

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

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

## Built on

- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md)
- [Badge](https://gelatinui.com/components/badge.md)
- [Breadcrumb](https://gelatinui.com/components/breadcrumb.md)
- [Button](https://gelatinui.com/components/button.md)
- [Dialog](https://gelatinui.com/components/dialog.md)
- [Kbd](https://gelatinui.com/components/kbd.md)

## 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

- [Dialog](https://gelatinui.com/components/dialog.md)
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md)
- [Drawer](https://gelatinui.com/components/drawer.md)
- [Breadcrumb](https://gelatinui.com/components/breadcrumb.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Escape | Closes the top level and moves focus back to its trigger. A level with unsaved edits asks first. |
| Alt + Left | Closes the top level when focus is not in a text field. |
| Tab | Moves focus inside the top level only. |

## Motion

| Part | Motion |
| --- | --- |
| Open | overlay · 200ms · the new level fades and scales in, and the level below steps back 4% and 8px up |
| Tint | overlay · 200ms · the level below gets a 10% tint; it goes on the overlay-exit clock |
| Close | overlay-exit · 150ms · the top level fades out, and the level below comes forward |
