Popover

Material Design 3-styled popover web component (lit-material-popover) — richer, click-triggered overlay content, distinct from the tooltip.

  • 2.0 KB gzipped
  • @lit-material/popover 0.0.3
  • Renders on the server

Example

Install

npm install @lit-material/popover @lit-material/tokens
import "@lit-material/popover";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-popover>

A richer, click-triggered overlay — a title, body content (arbitrary HTML, not just plain text), and optional footer actions — anchored to a trigger element. Distinct from lit-material-tooltip: that's hover/focus-triggered, plain text, and never gets a close button or interactive content of its own; this is deliberately closer to lit-material-menu's foundation (native Popover API, popover="auto" so outside-click/Escape light-dismiss come from the browser) than to tooltip's manual popover.

Properties

PropertyAttributeTypeDefaultDescription
openopenbooleanfalse
anchoranchorstring | undefinednoneid of the trigger element to position and return focus to. See also anchorElement.
dismissibledismissiblebooleantrueShows a close button in the header.
anchorElementproperty onlyHTMLElement | undefinednoneThe element the popover is positioned against and returns focus to on close.

Events

EventDescription
closeFires after the popover closes, for any reason (the close button, close(), Escape, or an outside click).

Slots

SlotDescription
headerOptional heading, next to the close button. Slot exactly one element.
defaultThe popover's body content.
footerOptional footer actions. For more than one, wrap them in a single element yourself so they end up in one row.

CSS parts

PartDescription
popoverThe popover surface (background, padding, shape, elevation).
headerThe header row. Always rendered; see dismissible.
closeThe close button. Only rendered when dismissible.
contentThe body content container.

Source on GitHub npm