Skip to main content
Dialogs display content in a modal overlay that focuses user attention. The first child is the trigger element, the thing users click to open the dialog. Everything after the first child becomes the dialog body. An optional title and description render in the dialog header. The dialog closes when the user clicks the X button, presses Escape, or clicks outside the overlay.
Clicking outside to dismiss may not work in the doc previews below due to how they’re sandboxed. It works in deployed apps.

Basic Usage

Confirmation Pattern

Dialogs work well for destructive actions that need explicit confirmation before proceeding. Use CloseOverlay() on the Cancel button to dismiss the dialog, and on the confirm button to close it after the action fires.

Confirmation with Feedback

Wire ShowToast callbacks onto a CallTool to give feedback after the server responds. CloseOverlay() in the on_success list dismisses the dialog once the operation succeeds; on_error keeps the dialog open so the user can retry.

State-Controlled Dialog

By default, dialogs open when the user clicks the trigger. Set name to bind the open state to a state variable, which lets you open the dialog programmatically via SetState. Both the trigger button and the external button open the same dialog: When name is set, SetState("show_help", True) opens the dialog and SetState("show_help", False) closes it. The trigger button still works too. Closing the dialog (via the X button, Escape, or clicking outside) writes False back to state. This is the mechanism behind keyboard shortcuts: bind a key to SetState(name, True) to open any dialog from the keyboard.

Non-Dismissible Dialog

Set dismissible=False when the user must make an explicit choice. Outside clicks, Escape, and the X button are all disabled. The only way to close the dialog is through a CloseOverlay() action on a button you provide:

API Reference

Dialog Parameters

str | None
default:"None"
Dialog header title.
str | None
default:"None"
Dialog header description text.
str | None
default:"None"
State key to bind open/close state. When set, the dialog can be opened programmatically via SetState(name, True). No initial state setup needed; the dialog defaults to closed.
bool
default:"True"
Whether the dialog can be closed by clicking outside, pressing Escape, or the X button. When False, the user must use an explicit CloseOverlay() action.
str | None
default:"None"
Additional Tailwind CSS classes.

Protocol Reference

Dialog
For the complete protocol schema, see Dialog.