Skip to content

Dialog Stack

Free

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.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 17, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

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

workspace-settings.tsx

DialogStack

PropTypeDefaultDescription
labels—The words the stack writes itself (the depth line, the folded chip, the Back name).
childrenReactNode—

DialogStackLevel

PropTypeDefaultDescription
labelRequiredstring—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).
From Base UIDialog.RootBase UI docs
openboolean—Whether the dialog is currently open.
defaultOpenbooleanfalseWhether the dialog is initially open. To render a controlled dialog, use the open prop instead.
modal"trap-focus" | booleantrueDetermines if the dialog enters a modal state when open. - true: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled. - false: user interaction with the rest of the document is allowed. - 'trap-focus': focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled. When modal is true or 'trap-focus', render <Dialog.Close> inside <Dialog.Popup> so touch screen readers can escape the popup.

DialogStackTrigger

<button>
PropTypeDefaultDescription
classNamestring—
From Base UIDialog.TriggerBase UI docs
handleDialogHandle<Payload>—A handle to associate the trigger with a dialog. Can be created with the Dialog.createHandle method.
payloadPayload—A payload to pass to the dialog when it is opened.
idstring—ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the dialog in controlled mode (with the DialogRoot triggerId prop).
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

DialogStackContent

<div>
PropTypeDefaultDescription
classNamestring—
backdropboolean—Dim the page under the dialog (Base UI Dialog.Backdrop). Default true.
showCloseButtonboolean—Show the close button (a 24px ghost icon button) in the top end corner. Default true.
portalProps—Other Base UI props of the inner parts. A className here adds to the component classes.
backdropPropsDialogOverlayProps—
viewportProps—
closeButtonProps—
scroll"inside""outside"—
From Base UIDialog.PopupBase UI docs
initialFocus—Determines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - false: Do not move focus. - true: Move focus based on the default behavior (first tabbable element or popup). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
finalFocus—Determines the element to focus when the dialog is closed. - false: Do not move focus. - true: Move focus based on the default behavior (trigger or previously focused element). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
container—A parent element to render the portal element into.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DialogStackNav

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DialogStackBack

<button>
PropTypeDefaultDescription
classNamestring—
busyboolean—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"
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

DialogStackPath

<nav>
PropTypeDefaultDescription
...props<nav> attributes—Every other attribute goes to the <nav>, with a ref.

DialogStackShortcut

<div>
PropTypeDefaultDescription
size"default""lg"—
variant"default""ghost"—
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DialogStackDepth

<p>
PropTypeDefaultDescription
...props<p> attributes—Every other attribute goes to the <p>, with a ref.

DialogStackGuard

<div>
PropTypeDefaultDescription
classNamestring—
portalProps—Other Base UI props of the inner parts. A className here adds to the component classes.
backdropPropsAlertDialogOverlayProps—
viewportProps—
size"default""sm""sm"
whenRequiredboolean—The level has unsaved changes: every close by the person asks first.
childrenReactNode—The question. Default: "Discard your changes?" with Keep editing and Discard.
From Base UIDialog.PopupBase UI docs
initialFocus—Determines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard. - false: Do not move focus. - true: Move focus based on the default behavior (first tabbable element or popup). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
finalFocus—Determines the element to focus when the dialog is closed. - false: Do not move focus. - true: Move focus based on the default behavior (trigger or previously focused element). - RefObject: Move focus to the ref element. - function: Called with the interaction type (mouse, touch, pen, or keyboard). Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.
container—A parent element to render the portal element into.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DialogStackGuardDiscard

<button>
PropTypeDefaultDescription
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"
classNamestring—
busyboolean—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.
From Base UIButtonBase UI docs
focusableWhenDisabledbooleanfalseWhether the button should be focusable when disabled.
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.
  • 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.
  • For one dialog with no level on top, use a Dialog.
  • For a single yes or no question, use an Alert Dialog.
  • For a panel from the edge of the screen, use a Drawer.
EscapeCloses the top level and moves focus back to its trigger. A level with unsaved edits asks first.
AltLeftCloses the top level when focus is not in a text field.
TabMoves focus inside the top level only.
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

Built with

Installs with Dialog Stack

  1. AddedDialog Stack, with Alert Dialog, Badge, Breadcrumb, Button, Dialog, Kbd.
Open the release