Components
Dialog

Dialog

The Dialog component is a powerful and highly customizable tool for creating dialog windows, also known as modals, in your application. It includes essential elements such as triggers, content, and close triggers.

API reference docs for the component. Learn about the props, CSS, and other APIs of this exported module.

DialogProps

aria-label

string

Human readable label for the dialog, in event the dialog title is not rendered

closeOnEsc

boolean

Whether to close the dialog when the escape key is pressed

closeOnOutsideClick

boolean

Whether to close the dialog when the outside is clicked

dir

'ltr' | 'rtl'

The document's text/writing direction.

finalFocusEl

HTMLElement | (() => MaybeElement)

Element to receive focus when the dialog is closed

getRootNode

() => ShadowRoot | Node | Document

A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

id

string

The unique identifier of the machine.

ids

Partial<{ trigger: string container: string backdrop: string content: string closeTrigger: string title: string description: string }>

The ids of the elements in the dialog. Useful for composition.

initialFocusEl

HTMLElement | (() => MaybeElement)

Element to receive focus when the dialog is opened

modal

boolean

Whether to prevent pointer interaction outside the element and hide all content below it

onEsc

VoidFunction

Callback to be invoked when the escape key is pressed

onOpenChange

(details: OpenChangeDetails) => void

Callback to be invoked when the dialog is opened or closed

onOutsideClick

VoidFunction

Callback to be invoked when the outside is clicked

open

boolean

Whether the dialog is open

preventScroll

boolean

Whether to prevent scrolling behind the dialog when it's opened

restoreFocus

boolean

Whether to restore focus to the element that had focus before the dialog was opened

role

'dialog' | 'alertdialog'

The dialog's role

trapFocus

boolean

Whether to trap focus inside the dialog when it's opened

DialogContext

backdropProps

Dict<any>

close

() => void

Function to close the dialog

closeTriggerProps

Dict<any>

containerProps

Dict<any>

contentProps

Dict<any>

descriptionProps

Dict<any>

isOpen

boolean

Whether the dialog is open

open

() => void

Function to open the dialog

titleProps

Dict<any>

triggerProps

Dict<any>

DialogContentProps

lazyMount

boolean

Whether to enable lazy mounting. Defaults to `false`.

onExitComplete

() => void

present

boolean

unmountOnExit

boolean

Whether to unmount on exit. Defaults to `false`.

DialogBackdropProps

lazyMount

boolean

Whether to enable lazy mounting. Defaults to `false`.

onExitComplete

() => void

present

boolean

unmountOnExit

boolean

Whether to unmount on exit. Defaults to `false`.