mica

Example

Anchored panelLight dismiss, Esc, toggling: all the browser. Anchored to the invoker where anchor positioning exists.

Basic usage

<button popovertarget="menu">Menu</button>

<div id="menu" popover class="menu">
  <button popovertarget="menu" popovertargetaction="hide">Edit</button>
  <button popovertarget="menu" popovertargetaction="hide">Duplicate</button>
  <hr />
  <button data-variant="danger" popovertarget="menu" popovertargetaction="hide">Delete</button>
</div>

<button data-tip="Saved" aria-label="Saved">Hover me</button>

API

Attributes

NameTypeDefaultDescription
popovernative attributeautoMakes an element a native popover.
popovertargetelement IDConnects an invoker button to a popover.
popovertargetactiontoggle | show | hidetoggleChooses the invoker action. Menu items use hide to close declaratively.
class="menu"classApplies menu layout to a popover of buttons or links.
data-tipstringAdds a CSS-only visual tooltip.

Content/markup contract

PartContractDefaultDescription
Panelelement with id and popoverrequiredContains arbitrary panel content.
Menu itemsbuttons or linksUse ordinary controls; separators are plain hr elements.
Tooltip labelaria-label or visible textrequireddata-tip itself is visual only.

Native methods

NameTypeDefaultDescription
showPopover()methodShows the popover from application code.
hidePopover()methodHides the popover from application code.
togglePopover()methodToggles the popover from application code.

Accessibility

Tab, Esc, and light dismiss are native. Tooltips are visual, so pair data-tip with an accessible name or visible text. Menus currently use normal tab order; arrow-key roving is not provided.

Browser support

Where CSS anchor positioning is unavailable, popovers fall back to the user agent's centered position.

← accordiontoast →