Popover / Bubble

Attribute-driven popover bubbles. Drop data-vd-bubble="…" on any element and the framework builds, positions, and wires the panel for you — with outside-click and Escape dismissal. Target-panel popovers also support overflow flipping, as shown below. data-vd-popover is a drop-in alias.

Following a moving anchor

Open either panel, then scroll inside the box or resize the window. The panel should follow its button. “No flip” keeps its bottom placement; “Auto flip” may switch sides near the viewport edge. Escape closes it.

Basic Popover
Placement Variants
With Title & Close Button
Body-only (No Title)
Engine wiring
API Reference

CSS Classes

ClassDescription
.vd-bubble-contentGenerated popover bubble container.
.vd-popover-contentAlias for .vd-bubble-content.
.vd-popover-panelTarget-panel popover container referenced by data-vd-popover-target.
.vd-popover-triggerOptional trigger class for target-panel popovers.
.vd-bubble-headerHeader bar (present only when data-vd-bubble-title is set; wraps the title <span> and close button).
.vd-bubble-closeClose button rendered in the header.
.vd-bubble-bodyBody content area.

Data Attributes

AttributeDescription
data-vd-bubblePopover text for attribute-built bubbles. (alias: data-vd-popover)
data-vd-bubble-placementtop | right | bottom | left. Default: bottom. (alias: data-vd-popover-placement)
data-vd-bubble-titleAdds a .vd-bubble-header with the given title and a close button. (alias: data-vd-popover-title)
data-vd-bubble-htmlRender trusted HTML content sanitised via sanitizeHtml. (alias: data-vd-popover-html)
data-vd-bubble-allow-svgBoolean attribute allowing <svg> tags inside data-vd-bubble-html. (alias: data-vd-popover-allow-svg)
data-vd-popover-targetCSS selector pointing to an authored .vd-popover-panel element.
data-vd-popover-triggerSpace-separated trigger modes for target panels: "click", "hover", "focus" (default "click focus").
data-vd-popover-flipSet to "false" to disable automatic viewport overflow flipping on target panels (default "true").

JavaScript Methods

MethodDescription
usePopover(root, options?)Wire every [data-vd-bubble] and [data-vd-popover-target] trigger inside root; returns a UsePopoverController.
UsePopoverOptions{ placement?: 'top' | 'bottom' | 'left' | 'right' ('bottom'), trigger?: string ('click focus'), flip?: boolean (true), hoverLeaveDelay?: number (80) }.
controller.show(trigger)Open the bubble/panel for a wired trigger element.
controller.hide(trigger)Close the bubble/panel for a wired trigger element.
controller.hideAll()Close every bubble and panel wired by this instance.
controller.refresh()Re-scan the root and wire triggers added since mount.

Events

EventDescription
bubble:showFired on an attribute-built bubble trigger when its bubble opens ({ trigger, placement }).
bubble:hideFired on an attribute-built bubble trigger when its bubble closes ({ trigger }).
popover:showFired on a target-panel trigger when its panel opens ({ trigger, placement }).
popover:hideFired on a target-panel trigger when its panel closes ({ trigger }).
Choosing a trigger

Use click/tap for popovers that users deliberately open or interact with. Use a real button so Enter and Space activate it. Keep Escape and outside-click dismissal available.

Use a tooltip for short, noninteractive hints shown on hover and keyboard focus. Avoid making hover the only way to access a popover: touch users cannot hover.

Accessibility
  • Trigger carries aria-haspopup="dialog" + toggled aria-expanded + aria-controls pointing at the generated panel.
  • Escape closes the most recently opened popover.
  • Click triggers close on outside click; resize / scroll recomputes placement and flips on overflow.
  • Content is sanitised; inline styles are stripped (v1.4.1+).