GitHub

Dialog

A modal window that appears on top of the main content.

Installation

Usage

Title and Description

You can use <DialogHeader /> in two ways:

Using props

You can pass title and description props directly to <DialogHeader />. In this case, you don't need to use <DialogTitle /> and <DialogDescription /> components.

Using components

Alternatively, you can use <DialogTitle /> and <DialogDescription /> as children for more control.

Examples

With ScrollArea

Make the content area scrollable while keeping header and footer fixed using ScrollArea.

No Close Button

Hide the close button in the top right corner by setting showCloseButton={false}.

Close behavior

Use closeOnInteractOutside and closeOnEscape props to prevent closing on outside click and escape.

Open from Menu

Open a dialog imperatively from a menu item using the onClick handler.

Confirmation

Intercept close attempts to show confirmation prompts, preventing data loss from unsaved changes.

Non-Modal

Use modal={false} to allow interaction with elements outside the dialog. Disables focus trapping and scroll prevention.

Initial Focus

Use initialFocusEl to control which element receives focus when the dialog opens.

Nested

Nest dialogs within one another.

API Reference

Dialog

Root element of the dialog. Renders a div.

DialogTrigger

Button that opens the dialog. Renders a button.

DialogContent

Container for the dialog content. Renders a div.

DialogHeader

Header container for the dialog. Renders a div.

DialogBody

Content container for the dialog. Renders a div wrapped in a ScrollArea.

DialogFooter

Footer container for the dialog. Renders a div.

DialogTitle

Title element for the dialog. Renders an h2.

DialogDescription

Description element for the dialog. Renders a div.

DialogClose

Button that closes the dialog. Renders a button.

DialogOverlay

Backdrop overlay for the dialog. Renders a div.


For a complete list of props, see the Ark UI documentation.