Import
Description
A modal dialog component that displays content in an overlay. The dialog component supports both a high-level API for simple use cases and a compositional API for advanced customization.High-Level API
Props
Component that triggers the dialog when clicked
The dialog title displayed in the header
Additional descriptive text shown below the title
Main content area of the dialog
Whether the dialog is initially open. Use when uncontrolled
Whether the dialog is currently open. Use for controlled state
When true, clicking outside the dialog won’t close it
Controls modal behavior:
True: Focus trapped, scroll locked, pointer interactions disabled outsideFalse: User can interact with rest of document'trap-focus': Focus trapped but scroll and pointer interactions enabled
Event Handlers
Called when dialog opens or closes. Receives the new open state
Called after animations complete when dialog opens or closes
Compositional API
For advanced use cases, use individual subcomponents:dialog.root()
Root container component that doesn’t render its own HTML element.Initial open state for uncontrolled usage
Current open state for controlled usage
Disable closing on outside click
Modal state behavior
Open state change handler
Handler called after animations complete
dialog.trigger()
Button that opens the dialog. Renders a<button> element.
Whether to render a native button element when using render prop
Custom component to render as the trigger
dialog.portal()
Portals the dialog to a different part of the DOM.Parent element selector to render portal into
Keep portal mounted in DOM while hidden
dialog.backdrop()
Overlay displayed beneath the popup. Renders a<div> element.
Force render even when nested
Custom component to render as backdrop
dialog.popup()
Container for dialog contents. Renders a<div> element.
Element selector to focus when dialog opens
Element selector to focus when dialog closes
Custom component to render as popup
dialog.title()
Heading that labels the dialog. Renders an<h2> element.
Custom component to render as title
dialog.description()
Paragraph with additional information. Renders a<p> element.
Custom component to render as description
dialog.close()
Button that closes the dialog. Renders a<button> element.
Whether to render a native button element when using render prop
Custom component to render as close button
Class Names
Access default class names viadialog.class_names:
BACKDROP: Overlay background stylingPOPUP: Dialog container stylingTITLE: Title text stylingDESCRIPTION: Description text stylingHEADER: Header container stylingCONTENT: Content container stylingTRIGGER: Trigger button stylingCLOSE: Close button styling