Popover
A floating panel anchored to a trigger element. Supports static HTML content or remote AJAX
content, hover (default) or click triggers, and smart viewport-aware placement.
The popover is rendered to <body> and uses position: absolute
so it scrolls naturally with the document — no JavaScript scroll tracking needed.
When the popover is clamped near a viewport edge the arrow always adjusts to keep pointing
at the trigger element. Popovers are ideal for contextual info cards, user profile previews,
and rich tooltips.
Basic Hover Popover
Default behaviour: shows on hover with a short delay, hides when the mouse leaves the
trigger or the popover itself. Placement defaults to auto (prefers bottom).
Click Trigger
Use ->triggerOn('click') for click-to-toggle behaviour.
Clicking outside the popover or pressing Escape dismisses it.
Placement
Explicit top, bottom, left, and right
placements, plus auto (default — flips to top when near the bottom edge).
Remote Content (AJAX)
Use ->remote(url) to load the popover body from an endpoint on first show.
Responses are cached per URL by default — set ->cache(false) to always
re-fetch. A spinner is shown while loading.
Shared Popover — User Profile Cards
A single popover instance can serve many triggers via ->triggerSelector().
Each trigger passes per-trigger overrides using data-popover-title and
data-popover-content (or data-popover-url for AJAX overrides).
This is the recommended pattern for user profile cards on a username list.
PHP PHP Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->popover($id) | Popover | Create a new popover component. |
->title($text) | self | Set the header title text. |
->content($html) | self | Set static HTML for the popover body. |
->trigger($elementId) | self | Bind to a single DOM element by ID. |
->triggerSelector($css) | self | Bind to all elements matching a CSS selector. |
->placement($p) | self | Placement: auto (default), top, bottom, left, right. |
->align($a) | self | Horizontal alignment for top/bottom placements: center (default), start (left-edge), end (right-edge). No effect on left/right placements. |
->triggerOn($event) | self | Trigger event: hover (default) or click. |
->delay($show, $hide) | self | Show/hide delays in ms. Default: 200 / 300. |
->remote($url) | self | Load body content from a URL via AJAX. |
->cache($bool) | self | Cache remote responses per URL. Default: true. |
->width($css) | self | Force a specific CSS width, e.g. '300px'. |
->offset($px) | self | Gap between trigger and popover in pixels. Default: 8. |
JS JS Methods
| Method / Property | Parameters | Description |
|---|---|---|
m.popover(id) | object|null | Get a popover instance by ID (auto-inits on DOMContentLoaded). |
pop.show(triggerEl) | | Show the popover anchored to an element. |
pop.hide() | | Hide the popover. |
pop.toggle(triggerEl) | | Toggle visibility for a trigger element. |
pop.setContent(html) | | Replace the body with arbitrary HTML. |
pop.setTitle(text) | | Update the header title text. |
pop.loadContent(url, force) | | Fetch content from a URL. Pass true to bypass cache. |
pop.bindTrigger(el) | | Bind a DOM element as a trigger (safe to call multiple times). |
pop.refresh() | | Re-scan the DOM for new trigger elements matching the configured selector. |
pop.element | HTMLElement | The underlying popover DOM element. |
EVENT Events
| Event Name | Detail | Description |
|---|---|---|
m:popover:show | { id, trigger } | Fired on the popover element when it becomes visible. |
m:popover:hide | { id } | Fired when the popover is hidden. |
m:popover:content-loaded | { id, url } | Fired after remote content is successfully loaded and injected. |