The ui5-dialog component is used to temporarily display some information in a size-limited window in front of the regular app screen. It is used to prompt the user for an action or a confirmation. The ui5-dialog interrupts the current app processing as it is the only focused UI element and the main screen is dimmed/blocked. The dialog combines concepts known from other technologies where the windows have names such as dialog box, dialog window, pop-up, pop-up window, alert box, or message box.
The ui5-dialog is modal, which means that an user action is required before it is possible to return to the parent window. To open multiple dialogs, each dialog element should be separate in the markup. This will ensure the correct modal behavior. Avoid nesting dialogs within each other. The content of the ui5-dialog is fully customizable.
Structure
A ui5-dialog consists of a header, content, and a footer for action buttons. The ui5-dialog is usually displayed at the center of the screen. Its position can be changed by the user. To enable this, you need to set the property draggable accordingly.
Responsive Behavior
The stretch property can be used to stretch the ui5-dialog on full screen.
CSS Shadow Parts
CSS Shadow Parts allow developers to style elements inside the Shadow DOM. The ui5-dialog exposes the following CSS Shadow Parts:
header - Used to style the header of the component
content - Used to style the content of the component
footer - Used to style the footer of the component
ES6 Module Import
import "@ui5/webcomponents/dist/Dialog";Note: We don't recommend nesting popup-like components (ui5-dialog, ui5-popover) inside ui5-dialog. Ideally you should create all popups on the same level inside your HTML page and just open them from one another, rather than nesting them.
Note: We don't recommend nesting popup-like components (ui5-dialog, ui5-popover) inside other components containing z-index. This might break z-index management.
Properties/Attributes
You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.
Name
Type
Default Value
Description
draggable
boolean
false
Determines whether the component is draggable. If this property is set to true, the Dialog will be draggable by its header.
Note: The component can be draggable only in desktop mode.
Note: This property overrides the default HTML "draggable" attribute native behavior. When "draggable" is set to true, the native browser "draggable" behavior is prevented and only the Dialog custom logic ("draggable by its header") works.
since v1.0.0-rc.9
headerText
header-text
string
""
Defines the header text.
Note: If header slot is provided, the headerText is ignored.
resizable
boolean
false
Configures the component to be resizable. If this property is set to true, the Dialog will have a resize handle in its bottom right corner in LTR languages. In RTL languages, the resize handle will be placed in the bottom left corner.
Note: The component can be resizable only in desktop mode. Note: Upon resizing, externally defined height and width styling will be ignored.
since v1.0.0-rc.10
state
ValueState
"None"
Defines the state of the Dialog.
Available options are: "None" (by default), "Success", "Warning", "Information" and "Error".
Note: If "Error" and "Warning" state is set, it will change the accessibility role to "alertdialog", if the accessibleRole property is set to "Dialog".
since v1.0.0-rc.15
stretch
boolean
false
Determines whether the component should be stretched to fullscreen.
Note: The component will be stretched to approximately 90% of the viewport.
accessibleName
accessible-name
string
undefined
Defines the accessible name of the component.
since v1.0.0-rc.15
accessibleNameRef
accessible-name-ref
string
""
Defines the IDs of the elements that label the component.
since v1.1.0
accessibleRole
accessible-role
PopupAccessibleRole
"Dialog"
Allows setting a custom role. Available options are:
Dialog
None
AlertDialog
since v1.10.0
initialFocus
initial-focus
string
""
Defines the ID of the HTML Element, which will get the initial focus.
open
boolean
false
Indicates if the element is open
since v1.2.0
preventFocusRestore
prevent-focus-restore
boolean
false
Defines if the focus should be returned to the previously focused element, when the popup closes.
since v1.0.0-rc.8
Slots
This Element provides slot(s). This means it can display its child nodes.
Unless targeting the default slot, use the slot attribute to define the destination slot for each child.
Text, along with HTML Elements with no slot attribute, goes the the default slot.
Slot
Type
Description
footer
HTMLElement [0..n]
Defines the footer HTML Element.
header
HTMLElement [0..n]
Defines the header HTML Element.
Note: If header slot is provided, the labelling of the dialog is a responsibility of the application developer. accessibleName should be used.
default
HTMLElement [0..n]
Defines the content of the Popup.
Events
This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.
Name
Description
after-close
Fired after the component is closed. This event does not bubble.
after-open
Fired after the component is opened. This event does not bubble.
before-close
Fired before the component is closed. This event can be cancelled, which will prevent the popup from closing. This event does not bubble.
escPressed
type: boolean description: Indicates that ESC key has triggered the event.
before-open
Fired before the component is opened. This event can be cancelled, which will prevent the popup from opening. This event does not bubble.
Methods
This Web Component exposes public methods. You can invoke them directly on the Web Component instance.
Name
Description
show
Shows the dialog.
preventInitialFocus
type: boolean description: Prevents applying the focus inside the popup
applyFocus
Focuses the element denoted by initialFocus, if provided, or the first focusable element otherwise.
close
Closes the popup.
isOpen
Tells if the component is opened
Theme:Morning Horizon (Light)Evening Horizon (Dark)Horizon High Contrast BlackHorizon High Contrast WhiteQuartz LightQuartz DarkQuartz High Contrast BlackQuartz High Contrast White