Skip to main content

A popup that opens on top of the entire page.

<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>
typo3 ui:add dialog

Read more about installing Components and Primitives.

Set role="alertdialog" and closeOnInteractOutside="{false}" with closeOnEscape="{false}" for critical confirmations like deleting an item. The Cancel button receives focus when the dialog opens, so the safest action comes first.

Put a dialog.root inside the content of another dialog. Each level opens on top of the previous one.

Use a popover for small anchored extras like share options. The dialog keeps its focus management.

When the content is taller than the viewport, the dialog scrolls as one piece, header and footer included. The dialog.positioner is the scroll container.

Keep the header and footer in view while the body scrolls: set a max-height on the dialog content and overflow-y: auto on the body.

Set closeOnInteractOutside="{false}" for a dialog the visitor should answer, like a cookie settings dialog. A click on the backdrop leaves it open.

Set closeOnEscape="{false}" to ignore the Escape key.

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.

Provides dialog state and context for the composed parts. Renders no wrapper element.

NameDescriptionRequiredDefault
trapFocusboolean
Whether to trap focus inside the dialog when it's opened.
No
true
preventScrollboolean
Whether to prevent scrolling behind the dialog when it's opened.
No
true
modalboolean
Whether to prevent pointer interaction outside the element and hide all content below it.
No
true
restoreFocusboolean
Whether to restore focus to the element that had focus before the dialog was opened.
No
true
closeOnInteractOutsideboolean
Whether to close the dialog when the outside is clicked.
No
true
closeOnEscapeboolean
Whether to close the dialog when the escape key is pressed.
No
true
roleEnum\DialogRole
The dialog's role.
No
Dialog
defaultOpenboolean
The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog.
No
false
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true

Opens the dialog. Renders a <button> element.

NameDescriptionRequiredDefault
valuestring
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-dialog-trigger<uid>
data-valueThe value of the item
data-state"open" | "closed"
data-currentPresent when current

Displays the overlay behind the dialog content. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-dialog-backdrop<uid>
data-state"open" | "closed"
data-nestedPresent when the backdrop is nested within another {{widget}}
data-has-nestedPresent when the backdrop has nested {{widget}}s

Positions the dialog content within the viewport. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-dialog-positioner<uid>
data-nestedPresent when the positioner is nested within another {{widget}}
data-has-nestedPresent when the positioner has nested {{widget}}s

Contains the dialog surface and interactive content. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Rendered data attributes

AttributeDescription
data-dialog-content<uid>
data-state"open" | "closed"
data-nesteddialog
data-has-nesteddialog

Provides the accessible title for the dialog. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Provides supporting descriptive text for the dialog. Renders a <div> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-

Closes the dialog when activated. Renders a <button> element.

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
NameTypeDescription
openbooleanWhether the dialog is open
setOpen(open: boolean) => voidFunction to open or close the dialog
triggerValuestring | nullThe active trigger value
setTriggerValue(value: string | null) => voidFunction to set the active trigger value
getTriggerState(props?: TriggerProps) => TriggerStateReturns the state of a specific trigger, including whether it's the currently active one
getBackdropState() => BackdropStateReturns the state of the backdrop
getPositionerState() => PositionerStateReturns the state of the positioner
getContentState() => ContentStateReturns the state of the content
KeyDescription
EnterWhen focus is on the trigger, opens the dialog.
TabMoves focus to the next focusable element within the content. Focus is trapped within the dialog.
Shift + TabMoves focus to the previous focusable element. Focus is trapped within the dialog.
EscCloses the dialog and moves focus to trigger or the defined final focus element