Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

popover

Turn any element into a top-layer popover with light dismiss. Covers auto, manual and hint popovers, how to open them, and what Vanilla Breeze does and does not style.

Overview

The popover attribute makes an element a popover: hidden until something opens it, then shown in the browser's top layer, above every other element whatever its z-index. Auto popovers close on light dismiss (a click outside or Escape). A button opens one with popovertarget or commandfor, with no script.

The Popover API shows and hides. It does not position: an open popover is position: fixed and the browser centres it in the viewport. Placing it next to its button is the job of CSS anchor positioning (see In Vanilla Breeze).

Applies to: any HTML element (it is a global attribute).

Values

ValueMeaning
auto, or the attribute with no value (popover / popover="")Light dismiss: a click outside or Escape closes it. Opening an auto popover closes the other open auto popovers, except its own ancestors, so nested menus work.
manualNo light dismiss and no Escape. It stays open until a button or script closes it. Any number can be open at once.
hintFor tooltips. Light dismiss like auto, but opening a hint closes only other hints and leaves open auto popovers alone. Usually opened by interestfor on hover or focus.
Any other valueTreated as manual. That includes hint in browsers that don't support it yet.
Attribute absentNot a popover.

The attribute is not inherited: a popover's children are ordinary elements.

Opening and closing

MechanismWhereWhat it does
popovertarget="id"<button>, button-type <input>Opens or closes the popover with that id.
popovertargetactionwith popovertargettoggle (default), show or hide.
commandfor="id" + command<button>toggle-popover, show-popover or hide-popover. The same commands also drive dialogs. See commandfor.
interestfor="id"<button>, <a>, <area>Opens after a short delay on hover or focus, and closes when the pointer or focus moves away. See interestfor.
showPopover(), hidePopover(), togglePopover()scriptThe same actions from JavaScript. togglePopover() returns the new open state.

Two events fire on the popover: beforetoggle (cancel it to stop a popover opening) and toggle. Both carry oldState and newState ("open" or "closed"). Style the open state with :popover-open.

Examples

Hint popover opened by interest

A popover="hint" target and an interestfor invoker make a tooltip with no script of your own. Vanilla Breeze styles [popover="hint"] as a tooltip and polyfills interestfor where the browser lacks it.

Invoker commands

commandfor and command do what popovertarget does, and the same attributes open dialogs.

Nested popovers

An auto popover opened from inside another stays a child of it: opening the child keeps the parent open, and a click outside both closes both.

Entry and exit transitions

A popover moves between display: none and the top layer, so animate it with @starting-style and discrete transitions of display and overlay. VB's tooltip styles use exactly this pattern.

In Vanilla Breeze

What is styled

Every popover gets three structural rules and no surface. In the reset layer (src/base/reset.css), a closed popover is display: none !important, the same mechanism VB uses for [hidden], so no element, component or author display can keep it on screen, and margin: auto (zero specificity) restores the browser's centring that VB's margin: 0 reset removes. <section>, <article> and <aside> popovers are not inline-size query containers (src/custom-elements/layout-attributes.css), so they size to their content. Beyond that, VB styles two kinds of popover, both in src/native-elements/tooltip/styles.css:

  • [role="tooltip"][popover]: an inverted surface (--color-text background, --color-text-inverted text), --font-size-s, at most 20rem wide, a fade and slide on open and close, an optional .tooltip-arrow child, and kbd and code tinted for the dark surface. It is position: fixed and placed above its trigger: with data-anchor (which data-tooltip sets) through a named anchor, otherwise through the invoker as implicit anchor, so a plain popovertarget click tip sits at its button too. Where anchor positioning is missing, data-tooltip places it with script.
  • [popover="hint"] (without role="tooltip"): the same surface and the same kbd / code tints, placed above its anchor with position-area: block-start and flipped below when there is no room (position-try-fallbacks: flip-block). Its timing, 200ms to open and 100ms to close, is set on the invoker ([interestfor]), where browsers and the polyfill read it.

Both get a border in forced-colours mode and no transition under reduced motion. Components style their own popovers: <pop-over> (the shared anchored surface for <tool-tip>, <drop-down>, <combo-box>, <context-menu> and others), <date-picker>, <page-tools> and <emoji-picker>.

What a bare popover gets

  • Browser styles only: a solid border, a little padding and Canvas colours.
  • Centred. Open and un-anchored, it sits in the middle of the viewport, as in a browser without VB. Anchor it (inset: auto plus position-area and your own margin) to place it beside its button.
  • Hidden when closed, on any element. To show a closed popover on purpose (a sidebar that is a popover only on small screens), remove the popover attribute at the sizes where it is a plain element; no display rule can override the reset. The dashboard layout's <nav popover> is the one framework exception.
  • Content-sized. A popover is not a query container, so container queries inside it resolve against the nearest container outside it.

Positioning

A button with popovertarget or commandfor becomes the popover's implicit anchor, so position-area alone places the popover next to it (the demo above does this). VB's interestfor support (src/utils/interest-polyfill.js) also writes a matching anchor-name / position-anchor pair on each invoker and target. Where anchor positioning isn't available, the polyfill and data-tooltip place the popover with script, and <pop-over> does the same for components.

VB features that read or set popover

  • data-tooltip (src/utils/tooltip-init.js) builds a role="tooltip" popover from a title, or wires a trigger to an existing one. Where popover="hint" isn't supported it uses manual and adds Escape and click-outside dismissal itself.
  • data-toggle sets aria-expanded on its button when the target is a popover.
  • <command-palette discover> lists [commandfor] buttons, so popover commands show up in the palette.

Accessibility

  • A popovertarget button exposes whether its popover is expanded, so you don't add aria-expanded yourself.
  • Popovers are not modal. Focus is not trapped and the rest of the page stays usable. When a task needs the page blocked, use <dialog> with showModal() or command="show-modal".
  • Opening a popover doesn't move focus into it unless an element inside has autofocus. In sequential focus order the popover's content comes straight after its invoker, so Tab reaches it next.
  • When a popover closes while focus is inside it, focus goes back to the element that had it before, usually the invoker.
  • role="tooltip" is for short, non-interactive text that describes its trigger (aria-describedby), shown on hover and focus and dismissible with Escape (WCAG 1.4.13). A bubble opened by a click is a toggletip or disclosure, not a tooltip.
  • A list of links in a popover is navigation, not an ARIA menu. Don't add role="menu" unless you also build the arrow-key behaviour; <drop-down> does that.
  • Give a popover that holds a landmark or heading a name, as with aria-label="Account" on the <nav> above.

Browser support

  • popover (auto, manual), popovertarget, :popover-open: Baseline 2024 (Chrome 114, Firefox 125, Safari 17).
  • popover="hint": Chrome 151, Firefox 153; not yet in a released Safari (as of November 2026). Chrome 133–150 and Firefox 149–152 shipped an older version of the spec.
  • Implicit anchor from the invoker: Chrome 133, Firefox 147, Safari 26.

Gotchas

  • No positioning. The Popover API never places a popover beside its button. Use anchor positioning, a component such as <pop-over>, or script.
  • ::backdrop applies to every open popover, not just manual ones. It is transparent by default; style it with [popover]::backdrop or a more specific selector.
  • Outside VB, closed popovers can stay visible when an author rule sets display: the browser's hiding rule is an ordinary declaration. VB re-asserts it with !important (see In Vanilla Breeze).
  • hint falls back to manual in older browsers: no light dismiss and no Escape. VB's data-tooltip adds dismissal back; a hand-built hint without it does not have it.
  • Escape closes the topmost auto or hint popover only. Manual popovers ignore it.
  • The target needs an id in the same tree (document or shadow root) as the button.

Related

Which to choose

  • popover (auto) — menus of links, toggletips, pickers: anything dismissible that doesn't block the page.
  • <dialog> with show-modal — a task the user must finish or cancel. It makes the rest of the page inert and traps focus. Add closedby="any" for light dismiss.
  • popover="hint" + interestfor — a plain-text tooltip in pure HTML.
  • data-tooltip — upgrade a title into a positioned tooltip with an arrow.
  • <tool-tip> — rich tooltips and hover cards with interactive content.
  • <pop-over> — an anchored popover with placement options and a no-anchor-positioning fallback.
  • <drop-down> — an action menu with arrow-key navigation.
  • data-toggle — flip some other attribute (hidden, open, data-state) from a button.
↑