Dialog
A popup that opens on top of the entire page.
Features
- Focus is trapped within the dialog and restored when closed
- Supports modal and non-modal modes
- Scrolling is blocked when dialog is open (in modal mode)
- Pressing
Escapecloses the dialog - Supports controlled and uncontrolled open state
Installation
typo3 ui:add dialog
Please copy the files manually from GitHub into your project.
Read more about installing Components and Primitives.
Examples
Alert Dialog
For critical confirmations or destructive actions, use role="alertdialog". Alert dialogs differ from regular dialogs in important ways:
- Automatic focus: The close/cancel button receives focus when opened, prioritizing the safest action
- Requires explicit dismissal: Cannot be closed by clicking outside, only via button clicks or Escape key
Nested Dialogs
Open a dialog from within another dialog.
Popover Inside Dialog
Render a popover inside dialog content when you need anchored secondary actions without breaking dialog focus management.
Scrollable Outside
The dialog positioner can scroll when the content exceeds the viewport height, so the entire dialog can scroll together.
Scrollable Inside
With some additions, the dialog content can scroll when it exceeds the viewport height, while keeping the header and footer visible.
Set a max-height on the content and use overflow-y: auto to enable scrolling inside the dialog's content area.
Prevent Close on Outside Click
Keep the dialog open when clicking outside.
Prevent Close on Escape
Disable closing the dialog with the Escape key.
API Reference
The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.
dialog.root
Provides dialog state and context for the composed parts. Renders no wrapper element.
| Name | Description | Required | Default |
|---|---|---|---|
trapFocus | booleanWhether to trap focus inside the dialog when it's opened. | No | true |
preventScroll | booleanWhether to prevent scrolling behind the dialog when it's opened. | No | true |
modal | booleanWhether to prevent pointer interaction outside the element and hide all content below it. | No | true |
restoreFocus | booleanWhether to restore focus to the element that had focus before the dialog was opened. | No | true |
closeOnInteractOutside | booleanWhether to close the dialog when the outside is clicked. | No | true |
closeOnEscape | booleanWhether to close the dialog when the escape key is pressed. | No | true |
role | stringThe dialog's role. | No | 'dialog' |
defaultOpen | booleanThe initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog. | No | false |
dialog.trigger
Opens the dialog. Renders a <button> element.
dialog.backdrop
Displays the overlay behind the dialog content. Renders a <div> element.
dialog.positioner
Positions the dialog content within the viewport. Renders a <div> element.
dialog.content
Contains the dialog surface and interactive content. Renders a <div> element.
dialog.title
Provides the accessible title for the dialog. Renders a <div> element.
dialog.description
Provides supporting descriptive text for the dialog. Renders a <div> element.
dialog.closeTrigger
Closes the dialog when activated. Renders a <button> element.
Anatomy
<primitives:dialog.root>
<primitives:dialog.trigger />
<primitives:dialog.backdrop />
<primitives:dialog.positioner>
<primitives:dialog.content>
<primitives:dialog.title />
<primitives:dialog.description />
</primitives:dialog.content>
</primitives:dialog.positioner>
</primitives:dialog.root>