Dialog

@ui5/webcomponents
<ui5-dialog>

Basic Dialog

Show Dialog
Register
<ui5-button id="openDialogButton" design="Emphasized">Open Dialog</ui5-button>

<ui5-dialog id="hello-dialog" header-text="Register Form">
	<section class="login-form">
		<div>
			<ui5-label for="username" required>Username: </ui5-label>
			<ui5-input id="username"></ui5-input>
		</div>

		<div>
			<ui5-label for="password" required>Password: </ui5-label>
			<ui5-input id="password" type="Password" value-state="Error"></ui5-input>
		</div>

		<div>
			<ui5-label for="email" type="Email" required>Email: </ui5-label>
			<ui5-input id="email"></ui5-input>
		</div>

		<div>
			<ui5-label for="address">Address: </ui5-label>
			<ui5-input id="address"></ui5-input>
		</div>
	</section>

	<div slot="footer"	class="dialog-footer">
		<div style="flex: 1;"></div>
		<ui5-button id="closeDialogButton" design="Emphasized">Register</ui5-button>
	</div>
</ui5-dialog>

<script>
	var dialogOpener = document.getElementById("openDialogButton");
	var dialog = document.getElementById("hello-dialog");
	var dialogCloser = document.getElementById("closeDialogButton");

	dialogOpener.accessibilityAttributes = {
		hasPopup: "dialog",
		controls: dialog.id,
	}

	dialogOpener.addEventListener("click", function() {
		dialog.show();
	});

	dialogCloser.addEventListener("click", function() {
		dialog.close();
	});
</script>
	

Draggable and Resizable Dialog

Open Draggable/Resizable dialog

Resize this dialog by dragging it by its resize handle.

This feature available only on Desktop.

Move this dialog around the screen by dragging it by its header.

This feature available only on Desktop.

OK
<ui5-dialog draggable resizable></ui5-dialog>
	

Dialog with SAP Fiori Styled Footer

Open dialog

Adding custom styles to achieve the look and feel of a SAP Fiori footer

OK Close
<ui5-dialog id="fiori-footer-dialog" header-text="SAP Fiori Styled Footer">
	<p>Adding custom styles to achieve the look and feel of a SAP Fiori footer</p>
	<div slot="footer" style="display: flex; align-items: center; justify-content: end; width: 100%; box-sizing: border-box;">
		<ui5-button  design="Emphasized" style="min-width: 4rem;">OK</ui5-button>
		<ui5-button style="margin: 0 0 0 0.5rem; min-width: 4rem;">Close</ui5-button>
	</div>
</ui5-dialog>
	

Dialogs with various state properties

Open error state dialog Open information state dialog Open success state dialog Open warning state dialog

Error state dialog

Close

Information state dialog

Close

Success state dialog

Close

Warning state dialog

Close
<ui5-dialog id="error-state-dialog" header-text="Error" state="Error">
	<p>Error state dialog</p>
	<div slot="footer" style="display: flex; justify-content: flex-end; width: 100%; padding: .25rem 1rem;">
		<ui5-button id="error-close">Close</ui5-button>
	</div>
</ui5-dialog>
	

Overview

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 Black Horizon High Contrast White Quartz Light Quartz Dark Quartz High Contrast Black Quartz High Contrast White
Content Density: Cozy Compact
Text Direction: LTR RTL
Apply Cancel