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
| Class | Description |
|---|---|
.vd-bubble-content | Generated popover bubble container. |
.vd-popover-content | Alias for .vd-bubble-content. |
.vd-popover-panel | Target-panel popover container referenced by data-vd-popover-target. |
.vd-popover-trigger | Optional trigger class for target-panel popovers. |
.vd-bubble-header | Header bar (present only when data-vd-bubble-title is set; wraps the title <span> and close button). |
.vd-bubble-close | Close button rendered in the header. |
.vd-bubble-body | Body content area. |
Data Attributes
| Attribute | Description |
|---|---|
data-vd-bubble | Popover text for attribute-built bubbles. (alias: data-vd-popover) |
data-vd-bubble-placement | top | right | bottom | left. Default: bottom. (alias: data-vd-popover-placement) |
data-vd-bubble-title | Adds a .vd-bubble-header with the given title and a close button. (alias: data-vd-popover-title) |
data-vd-bubble-html | Render trusted HTML content sanitised via sanitizeHtml. (alias: data-vd-popover-html) |
data-vd-bubble-allow-svg | Boolean attribute allowing <svg> tags inside data-vd-bubble-html. (alias: data-vd-popover-allow-svg) |
data-vd-popover-target | CSS selector pointing to an authored .vd-popover-panel element. |
data-vd-popover-trigger | Space-separated trigger modes for target panels: "click", "hover", "focus" (default "click focus"). |
data-vd-popover-flip | Set to "false" to disable automatic viewport overflow flipping on target panels (default "true"). |
JavaScript Methods
| Method | Description |
|---|---|
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
| Event | Description |
|---|---|
bubble:show | Fired on an attribute-built bubble trigger when its bubble opens ({ trigger, placement }). |
bubble:hide | Fired on an attribute-built bubble trigger when its bubble closes ({ trigger }). |
popover:show | Fired on a target-panel trigger when its panel opens ({ trigger, placement }). |
popover:hide | Fired 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"+ toggledaria-expanded+aria-controlspointing 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+).