Popover

Progressive-enhancement patterns using the native Popover API, with no JavaScript required for basic toggling and light dismiss.

The trigger declares the entire relationship

Popover API attributes provide toggling, Escape dismissal, and light dismiss without application JavaScript.

Project actions

More examples

Each example introduces a different part of the shipped API.

Auto, manual, and hint modes express lifecycle

Choose behavior in markup; do not simulate a modal by styling an ordinary popover.

auto

Light dismiss

manual

Explicit control

hint

Nonessential hint

The native Popover API handles top-layer placement, Escape dismissal, and light dismiss. CSS Tags styles any element with the popover attribute.

Native popover

Open it, press Escape, or click outside to dismiss.

Signed in as Adaada@example.com
<button type="button" popovertarget="account-popover">
Account details
</button>
<div id="account-popover" popover="auto">
<strong>Signed in as Ada</strong>
<p>ada@example.com</p>
<button
type="button"
popovertarget="account-popover"
popovertargetaction="hide"
>
Close
</button>
</div>

Choosing a popover mode

ValueBehaviorTypical use
popover or popover="auto"Light dismiss and one auto popover at a timeMenus and account panels
popover="manual"Opens and closes only when explicitly requestedPersistent teaching UI
popover="hint"Hint-style relationship where supportedNonessential hover/focus hints

Popover content is non-modal: it does not make the rest of the page inert or trap focus. Use a native <dialog> when the user must respond before continuing.

Theme tokens

[popover] {
--b-bg: var(--surface-default);
--b-bc: var(--outline-default);
--b-bw: 1px;
--b-r: var(--radius-lg);
--b-p: var(--space-lg);
--popover-max-width: 24rem;
--popover-max-height: 32rem;
}

Popovers are centered in the top layer by default, which remains reliable when anchor positioning is unavailable. Add data-scrim when the popover benefits from a dimmed backdrop; ordinary non-modal popovers keep the page unobscured.

Progressive enhancement

The trigger and popover attributes provide the behavior without application JavaScript in supporting browsers. If older browsers are in scope, keep essential actions available elsewhere or load a focused Popover API polyfill. Do not hide critical navigation exclusively inside an unsupported popover.

Accessibility checklist

  • Use a real <button> as the trigger.
  • Give icon-only triggers an accessible name.
  • Keep focusable controls in a logical DOM order.
  • Use menu roles only when you also implement the complete keyboard interaction expected of an application menu.