Panels for menus, pickers, and other content that opens over the page, using the native Popover API. Any element with the [popover] attribute inside .mdst-ui is styled with no class; elsewhere, use .mdst-popover. Open them with popovertarget or command, no JavaScript needed.
Variants
| Class | Example |
|---|---|
| .mdst-popover | |
| .mdst-popover--sm | |
| .mdst-popover--lg | |
| .mdst-popover--anchored |
Attributes
| Attribute | Description |
|---|---|
| popover | Auto-dismiss popover (closes on outside click or ESC) |
| popover="manual" | Manual popover (requires explicit close) |
| popovertarget="id" | On a button: toggles the popover with that id, no JavaScript needed |
| commandfor="id" command="…" | On a button: toggle-popover, show-popover, or hide-popover. Also opens and closes dialogs |
| anchor="id" | Anchors popover to an element (use with --anchored) |
Usage
<!-- Classless (inside .mdst-ui container) -->
<div class="mdst-ui">
<button popovertarget="my-popover">Toggle Popover</button>
<div id="my-popover" popover>
<p>Popover content</p>
</div>
</div>
<!-- Class-based, opened with the command attributes (no JavaScript) -->
<button commandfor="menu" command="toggle-popover">Open Menu</button>
<div id="menu" class="mdst-popover" popover>
<p>Menu content</p>
<button commandfor="menu" command="hide-popover">Close</button>
</div>
<!-- Anchored popover -->
<button id="trigger" popovertarget="anchored">Open Menu</button>
<div id="anchored" class="mdst-popover mdst-popover--anchored" popover anchor="trigger">
<p>Anchored below the button</p>
</div>
<!-- Manual popover -->
<div id="manual" class="mdst-popover" popover="manual">
<p>Won't close on outside click</p>
</div>
This is a default popover. Click outside or press ESC to close.
Compact popover
Large Popover
This is a larger popover with more room for content.