DialogElement
<vaadin-dialog> is a Web Component for creating customized modal dialogs.
<vaadin-dialog header-title="Title">
<div>Dialog content</div>
<div slot="footer">Footer</div>
</vaadin-dialog>Slots
Dialog supports following slots for providing content:
| Name | Description |
|---|---|
| (none) | Default slot for the content |
header-content | Slot for the header content |
footer | Slot for the footer content |
Renderer (deprecated)
The content of the dialog can also be populated by using the renderer callback functions, although this approach is deprecated in favor of slotted content.
The renderer function provides root, dialog arguments. Generate DOM content, append it to the root element and control the state of the host element by accessing dialog. Before generating new content, users are able to check if there is already content in root for reusing it.
<vaadin-dialog id="dialog"></vaadin-dialog>const dialog = document.querySelector('#dialog');
dialog.renderer = function(root, dialog) {
root.textContent = "Sample dialog";
};Renderer is called on the opening of the dialog. DOM generated during the renderer call can be reused in the next renderer call and will be provided with the root argument. On first call it will be empty.
Styling
The following shadow DOM parts are available for styling:
| Part name | Description |
|---|---|
backdrop | Backdrop of the overlay |
overlay | The overlay container |
content | The overlay content |
header | Element wrapping title and header content |
header-content | Element wrapping the header content slot |
title | Element wrapping the title slot |
footer | Element wrapping the footer slot |
The following state attributes are available for styling:
| Attribute | Description |
|---|---|
has-title | Set when the element has a title |
has-header | Set when the element has header content |
has-footer | Set when the element has footer content |
overflow | Set to top, bottom, none or both |
The following custom CSS properties are available for styling:
| Custom CSS property |
|---|
--vaadin-dialog-background |
--vaadin-dialog-border-color |
--vaadin-dialog-border-radius |
--vaadin-dialog-border-width |
--vaadin-dialog-max-width |
--vaadin-dialog-min-width |
--vaadin-dialog-overflow-indicator-color |
--vaadin-dialog-overflow-indicator-height |
--vaadin-dialog-padding |
--vaadin-dialog-shadow |
--vaadin-dialog-text-color |
--vaadin-dialog-title-color |
--vaadin-dialog-title-font-size |
--vaadin-dialog-title-font-weight |
--vaadin-dialog-title-line-height |
--vaadin-dialog-toolbar-gap |
--vaadin-overlay-backdrop-background |
See Styling Components documentation.
Properties
Custom function for rendering the dialog footer. Receives two arguments:
Custom function for rendering the dialog header. Receives two arguments:
String used for rendering a dialog title.
Set to true to prevent the dialog from moving outside the viewport bounds. When enabled, all four edges of the dialog will remain visible, for example when dragging the dialog or when the viewport is resized. Note that the dialog will also adjust any programmatically configured size and position so that it stays within the viewport.
Set to true to prevent focus from moving into the dialog on open.
Set to true to disable closing dialog on Escape press
Set to true to disable closing dialog on outside click
Set to true to prevent the dialog from receiving focus on open and trapping it inside.
The role attribute value to be set on the dialog. Defaults to "dialog".
Custom function for rendering the content of the dialog. Receives two arguments:
Functions
Requests an update for the content of the dialog. While performing the update, it invokes the renderer passed in the renderer property, as well as headerRender and footerRenderer properties, if these are defined.