Dialog
Modal content with focus management and composable actions.
Modal content with focus management and composable actions.
Backed by Base UI Dialog for upstream behavior and configuration. Zenos owns the public API, styling, and composition shown on this page.
Dialog.Root
├── Dialog.Trigger
└── Dialog.Content
├── Dialog.Header
│ ├── Dialog.Title
│ └── Dialog.Description
├── Content
└── Dialog.Footer
└── Dialog.Close
Import
Section titled “Import”import { Dialog } from "@zentara-co/zenos-ui";Composition and actions
Section titled “Composition and actions”Dialog.Trigger and Dialog.Close are already styled buttons. Use their variant and size
props for standard controls. Use Base UI’s render composition only when another ref-forwarding
component must own the rendered element.
Use Dialog.Close for actions that always dismiss, such as Cancel or Done. For work that can fail
or finish asynchronously, use a regular Button and update the controlled open state only after
the operation succeeds.
Controlled state
Section titled “Controlled state”Use open and onOpenChange when application state must observe every opening and closing path.
The example closes from application code after saving while Cancel, Escape, and allowed outside
interaction continue through onOpenChange.
Dialog is closed.
Dismissal behavior
Section titled “Dismissal behavior”Dialogs dismiss from their trigger, Close controls, Escape, and outside presses by default. Set
disablePointerDismissal when an accidental outside press would interrupt important work. Escape
and explicit Close controls remain available.
Set showCloseButton={false} only when another clearly labeled Dialog.Close is always present.
Use AlertDialog instead when a destructive or irreversible action requires an explicit decision.
Width and surface styling
Section titled “Width and surface styling”The default surface is max-w-lg. Override dimensions and padding through className on
Dialog.Content. Use overlayClassName for the backdrop and viewportClassName for viewport
spacing or alignment. Prefer semantic tokens for the dialog surface itself.
The backdrop still renders when the dialog is nested inside another dialog, including a closed
sheet. Dialog.Overlay uses forceRender for that case. Pass forceRender={false} only when a
nested dialog should leave the page undimmed.
Scrollable content
Section titled “Scrollable content”Enable scrollable for content that may exceed the viewport. Dialog constrains the surface to 90%
of the viewport height and creates an internal scroll region. Headers, body content, and footers
inside that region scroll together.
Focus management
Section titled “Focus management”Focus moves to the first tabbable element when the dialog opens and returns to its trigger when it
closes. Pass initialFocus or finalFocus to Dialog.Content only when the default order is not
appropriate. Avoid initially focusing a destructive action.
Dialog.Content creates the portal, overlay, viewport, and popup while preserving Base UI focus
trapping, Escape handling, outside interaction, and focus return. Use its styling props instead of
wrapping Content in another portal or overlay.
Dialog.Root Dialog.Trigger Dialog.Content Dialog.Header Dialog.Title Dialog.Description Dialog.Footer Dialog.Close
API
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | — | Controlled open state. |
defaultOpen | boolean | false | Initial uncontrolled open state. |
onOpenChange | (open: boolean, eventDetails) => void | — | Runs for trigger, Close, Escape, outside press, and controlled changes. |
onOpenChangeComplete | (open: boolean) => void | — | Runs after opening or closing animations finish. |
modal | boolean | trap-focus | true | Controls focus trapping, page scroll locking, and outside interaction. |
disablePointerDismissal | boolean | false | Prevents outside pointer presses from closing the dialog. |
render (Trigger / Close) | ReactElement | function | — | Composes Trigger and Close with another element. |
initialFocus / finalFocus (Content) | Ref | function | — | Customizes entry and return focus. |
scrollable (Content) | boolean | false | Constrains tall content and enables internal overflow scrolling. |
showCloseButton (Content) | boolean | true | Shows the automatic icon close control. |
closeLabel (Content) | string | Close | Accessible name for the automatic close control. |
variant / size (Trigger / Close) | ButtonVariant / sm | md | lg | primary / md (Trigger), outline / md (Close) | Styles the built-in button controls. |
className (Content) | string | — | Overrides popup width, spacing, and surface styling. |
overlayClassName (Content) | string | — | Adds classes to the generated modal backdrop. |
forceRender (Overlay) | boolean | true | Renders the backdrop when the dialog is nested inside another dialog, including a closed sheet. |
viewportClassName (Content) | string | — | Adds classes to the generated positioning viewport. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Give every dialog a meaningful Dialog.Title; add Dialog.Description when the scope or
consequence needs explanation. The automatic icon button uses closeLabel; customize it when
“Close” lacks enough context. Keep at least one explicit close path in modal dialogs, preserve a
logical tab order, and do not use Dialog as a substitute for AlertDialog confirmation semantics.