Lion Logo Lion Fundamentals Guides Components Blog Toggle darkmode

Overlays: Overview

Supports different types of overlays like dialogs, toasts, tooltips, dropdown, etc.

Manages their position on the screen relative to other elements, including other overlays.

Its purpose is to make it easy to use our Overlay System declaratively. It can be easily extended where needed, to override event listeners and more.

See lion-dialog and lion-tooltip for example Web Component implementations using the Overlay System.


  • local rendering (at dom location)
    • positioning with popper.js
  • global rendering (at body level)
  • fully accessible
  • flexible to build multiple overlay components
  • lion-overlay web component:
    • Show content when clicking the invoker
    • Have a .config object to set or update the OverlayController's configuration
  • OverlaysManager, a global repository keeping track of all different types of overlays
  • OverlayController, a single controller class for handling overlays
  • OverlayMixin, a mixin that can be used to create webcomponents that use the OverlayController under the hood

Usually you will use lion-dialog (or lion-tooltip if this makes more sense).


npm i --save @lion/ui


import '@lion/ui/define/lion-dialog.js';

  <lion-dialog .config=$>
    <div slot="content">
      This is an overlay
        @click=${e => Event('close-overlay', { bubbles: true }))}
    <button slot="invoker">
      Click me

Or by creating a controller yourself

import { OverlayController } from '@lion/ui/overlays.js';

const ctrl = new OverlayController({

Or creating your own Web Component which uses the Overlay System

import { LitElement, html } from 'lit';
import { OverlayMixin, withModalDialogConfig } from '@lion/ui/overlays.js';

class MyOverlayComponent extends OverlayMixin(LitElement) {
  _defineOverlayConfig() {
    return {

  _setupOpenCloseListeners() {
    this.__toggle = () => {
      this.opened = !this.opened;

    if (this._overlayInvokerNode) {
      this._overlayInvokerNode.addEventListener('click', this.__toggle);

  _teardownOpenCloseListeners() {

    if (this._overlayInvokerNode) {
      this._overlayInvokerNode.removeEventListener('click', this.__toggle);

  render() {
    return html`
      <slot name="invoker"></slot>
      <div id="overlay-content-node-wrapper">
        <slot name="content"></slot>


Please check the system rationals folder, where we go more in-depth.