OverlayElement
<vaadin-overlay> is a Web Component for creating overlays. The content of the overlay can be populated imperatively by using renderer callback function.
Rendering
The renderer function provides root, owner, model arguments when applicable. Generate DOM content by using model object properties if needed, append it to the root element and control the state of the host element by accessing owner. Before generating new content, users are able to check if there is already content in root for reusing it.
<vaadin-overlay id="overlay"></vaadin-overlay>const overlay = document.querySelector('#overlay');
overlay.renderer = function(root) {
root.textContent = "Overlay content";
};Renderer is called on the opening of the overlay and each time the related model is updated. 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 | Container for position/sizing/alignment of the content |
content | Content of the overlay |
The following state attributes are available for styling:
| Attribute | Description |
|---|---|
opening | Applied just after the overlay is opened. You can apply a CSS animation for this state. |
closing | Applied just before the overlay is closed. You can apply a CSS animation for this state. |
The following custom CSS properties are available for styling:
| Custom CSS property | Description | Default value |
|---|---|---|
--vaadin-overlay-viewport-bottom | Bottom offset of the visible viewport area | 0 or detected offset |
See Styling Components documentation.
Properties
When set to true, the overlay is hidden. This also closes the overlay immediately in case there is a closing animation in progress.
Custom function for rendering the content of the overlay. Receives three arguments:
Set to specify the element which should be focused on overlay close, if restoreFocusOnClose is set to true.
Set to true to enable restoring of focus when overlay is closed.
When true the overlay has backdrop on top of content when opened.
Functions
Brings the overlay as visually the frontmost one.
Requests an update for the content of the overlay. While performing the update, it invokes the renderer passed in the renderer property.
Updates the coordinates of the overlay.