
Modal dialog with focus trap, backdrop, and controlled state.
pnpm dlx edbn-ui@latest add dialogCreate a file and paste the following code into it.
Groups all parts of the dialog. Doesn't render its own HTML element.
defaultOpenbooleanfalseInitial open state
openbooleanControlled open state
onOpenChange(open: boolean, eventDetails: Dialog.Root.ChangeEventDetails) => voidCalled when the dialog opens or closes
modalboolean | 'trap-focus'trueControls focus trapping, scroll lock, and outside interaction
disablePointerDismissalbooleanfalseDisable backdrop dismiss
onOpenChangeComplete(open: boolean) => voidCalled after animation completes
actionsRefRefObject<Dialog.Root.Actions | null>Imperative close and unmount actions
handleDialog.Handle<Payload>Handle for detached triggers
defaultTriggerIdstring | nullInitial associated trigger id
triggerIdstring | nullControlled associated trigger id
childrenReactNode | PayloadChildRenderFunction<Payload>Dialog content or payload-aware render child
A button that opens the dialog. Renders a button element.
handleDialog.Handle<Payload>Associates this trigger with a detached root
payloadPayloadPayload passed to a render-child root
idstringElement and active trigger id
nativeButtonbooleantrueRender as native button
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-popup-open | Present when dialog is open |
| data-disabled | Present when disabled |
Moves the popup to a different part of the DOM. Renders a div element.
containerHTMLElement | ShadowRoot | RefObject | nullPortal container
keepMountedbooleanfalseKeep in DOM when closed
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
An overlay displayed beneath the popup. Renders a div element.
forceRenderbooleanfalseForce rendering even when nested
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when dialog is open |
| data-closed | Present when dialog is closed |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
A positioning container for scrollable dialogs. Renders a div element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when dialog is open |
| data-closed | Present when dialog is closed |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
| data-nested | Present when nested within another dialog |
| data-nested-dialog-open | Present when nested dialogs are open within |
A container for the dialog contents. Renders a div element.
initialFocusboolean | RefObject<HTMLElement> | functionElement to focus on open
finalFocusboolean | RefObject<HTMLElement> | functionElement to focus on close
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-open | Present when dialog is open |
| data-closed | Present when dialog is closed |
| data-starting-style | Present when animating in |
| data-ending-style | Present when animating out |
| data-nested | Present when nested within another dialog |
| data-nested-dialog-open | Present when nested dialogs are open within |
| Variable | Description |
|---|---|
| --nested-dialogs | Number of dialogs nested within |
A heading that labels the dialog. Renders an h2 element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
A paragraph with additional information. Renders a p element.
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
A button that closes the dialog. Renders a button element.
nativeButtonbooleantrueRender as native button
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
| Attribute | Description |
|---|---|
| data-disabled | Present when disabled |
EDBN styled corner close button built on Dialog.Close with an icon and accessible label.
aria-labelstring'Close dialog'Accessible label for the icon button
nativeButtonbooleantrueRender as native button
classNamestring | functionCSS class name
styleCSSProperties | functionInline style or state-based style function
renderReactElement | functionCustom render function
EDBN layout helper for grouping DialogTitle and DialogDescription. Renders a div element.
classNamestringCSS class name
EDBN layout helper for dialog actions. Renders a div element.
classNamestringCSS class name
Base UI handle utility for detached triggers and imperative dialog control.
isOpenbooleanreadonlyWhether the associated dialog is open
open(triggerId: string | null) => voidmethodOpen and associate the dialog with a trigger id
openWithPayload(payload: Payload) => voidmethodOpen with payload for render-child dialog roots
close() => voidmethodClose the associated dialog
Function exported as createDialogHandle for creating typed detached-trigger handles.
returnDialog.Handle<Payload>A new imperative dialog handle