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

pop-over

General-purpose anchored popover container. Wraps the native Popover API with CSS Anchor Positioning, JS fallback, and cascade-layer-aware hiding.

Overview

The <pop-over> component is a thin primitive over the native Popover API. It applies the popover attribute, wires CSS Anchor Positioning when supported, falls back to JS-driven fixed positioning otherwise, and re-asserts display: none under VB's authored cascade layers (where the UA hiding rule loses to authored styles).

It is the shared popover surface for <tool-tip>, <drop-down>, <combo-box>, <context-menu>, <selection-menu> and <reaction-bar>.

Attributes

AttributeValuesDefaultDescription
data-mode"auto", "manual", "hint"autoPopover type: 'auto' (default, light-dismiss + Escape, closes other auto popovers), 'manual' (script-only), 'hint' (light-dismiss without closing open auto popovers; falls back to 'auto' where popover="hint" is unsupported). Hover opening is not wired (use interestfor or tool-tip). Changes after upgrade re-apply the popover attribute; an authored popover attribute wins at upgrade.
data-anchorstring—ID (or CSS selector) of the anchor element to position against. If omitted, the component uses the first element whose popovertarget points at this pop-over. Changes after upgrade re-wire the anchor.
data-position"top", "bottom", "left", "right", "top-start", "top-end", "bottom-start", "bottom-end", "left-start", "left-end", "right-start", "right-end"bottomWhere to place the popover relative to the anchor; -start/-end are logical (mirror in RTL). Flips to the opposite side instead of overflowing the viewport. Default: 'bottom'.
data-offset"none", "xs", "s", "m", "l"xsGap between popover and anchor, mapped to --size-* tokens. Default: 'xs'.
data-anchor-name (reflected)string—Set by the runtime when an anchor is bound with CSS Anchor Positioning: the dashed-ident appended to the anchor's anchor-name and used as this host's position-anchor. Absent when there is no anchor or no anchor-positioning support.

A missing data-position means bottom: centred below the anchor. -start and -end are logical, so they mirror in right-to-left text. When the preferred side doesn't fit, the popover flips to the opposite side. data-mode, data-anchor and data-position can change after upgrade; the component re-applies the popover type and re-wires the anchor.

Several pop-overs can share one anchor (for example a tool-tip and a drop-down on the same button). Each one appends its own name to the anchor's anchor-name list and removes only that name when it disconnects.

JavaScript API

MemberDescription
.show()Open the popover. Does nothing if it is already open.
.hide()Close the popover. Does nothing if it is already closed.
.toggle()Open if closed, close if open.
.openRead-only boolean, true while the popover is open.

Events

EventDetailDescription
pop-over:show{ state: 'open' }Fired (bubbles, composed) on beforetoggle as the popover opens, whether by popovertarget, show() or showPopover().
pop-over:hide{ state: 'closed' }Fired (bubbles, composed) on beforetoggle as the popover closes, including light-dismiss and Escape.

Usage

Standard trigger via popovertarget

Manual mode (script controls)

A manual pop-over with no anchor (no data-anchor and no popovertarget trigger) keeps the browser's default centring in the viewport.

Progressive Enhancement

  1. HTML. Author the popover attribute yourself (<pop-over id="prefs" popover>) and the popover works before, or without, script: the browser hides it and popovertarget buttons open it, centred in the viewport. Without the attribute, the host stays hidden until the component upgrades.
  2. CSS. Where CSS Anchor Positioning is supported (Chrome and Edge 125+, Safari 26+), placement is declarative and no script runs on resize or scroll.
  3. JS. The component sets the popover type and wires the anchor. In browsers without anchor positioning it places the popover with fixed coordinates after it opens, flips it to the other side when it doesn't fit, and keeps it inside the viewport.

data-mode="hint" needs popover="hint" support (Chrome 151, Firefox 153; Chromium 133–150 shipped an earlier partial version). Elsewhere the component uses auto instead, so light-dismiss and Escape still work. Hint mode does not open on hover: hover and focus triggers need interestfor or <tool-tip>.

Accessibility

  • The host has no role. <pop-over> is a positioning primitive, so you supply the semantics for what it contains: role="dialog" with an accessible name for interactive content, a <menu> or list for actions, or role="tooltip" for a description. The composing components (drop-down, combo-box, tool-tip, context-menu) set their own roles.
  • aria-expanded on the trigger and focus return on close come from the browser only when the trigger is a native popovertarget button. Opening with .show() or anchoring with data-anchor gives you neither, so set aria-expanded yourself (listen for pop-over:show and pop-over:hide) and move focus back to the trigger when it closes.
  • auto and hint popovers close on Escape and on a click outside. manual popovers do not, so give them a visible close button.
  • Opening a popover does not move focus into it. If its content needs focus, focus the first control from a pop-over:show listener, or use <dialog> for modal content.
  • The surface has a border as well as a shadow, so its edge stays visible in forced-colors mode.

Why a primitive

Popover logic used to live inside tool-tip only. As context-menu, drop-down, selection-menu, and combo-box all need the same behavior — including the cascade-layer display: none re-assertion — having one primitive avoids re-implementing positioning, light-dismiss, and the cascade gotcha in five places.

↑