Popover
A small floating panel with real content — details, a confirmation, a short form — anchored to its button. Bigger than a tooltip, lighter than a dialog.
Payment
It can't be undone.
Admin · jane@moey.test
Corner close & outside click
Select orders in the table and refund them in one go.
A popover with no way to close inside it — no ✕, no Cancel — gets the round corner ✕ automatically, like a notification badge (it doesn't close on an outside click, so there's always a visible way out). Not for hover cards or data-moey-close-outside popovers; data-moey-close="false" turns it off. Write it yourself to color it or to add it next to a header.
<div class="popover" id="whats-new">
<div class="popover-body">…</div> <!-- gets the corner ✕ by itself -->
</div>
<button class="popover-close theme-red" aria-label="Close"></button> <!-- any theme color -->
<div class="popover" data-moey-close-outside="true">…</div> <!-- a click outside closes it -->
Forms in a popover
Use <form method="dialog">: pressing Enter or the submit button checks the fields (e.g. required), fires the usual submit event for your code, then closes the popover — just like in a dialog.
<button class="btn" data-moey-open="#filter">Filter orders</button>
<div class="popover" id="filter">
<form method="dialog">
<div class="popover-header">
<h3 class="popover-title">Filter orders</h3>
…
</div>
<div class="popover-body">…fields…</div>
<div class="popover-footer">
<button type="reset" class="btn btn-ghost btn-sm">Reset</button>
<button type="submit" class="btn btn-default btn-sm">Apply filters</button>
</div>
</form>
</div>
form.addEventListener('submit', () => {
const data = new FormData(form); // status, date, min, max…
loadOrders(data); // the popover closes by itself
});
Tips: give buttons that shouldn't submit type="button" (like Cancel, with data-moey-dismiss); autofocus on a field puts the cursor there when the popover opens; Esc or a click outside closes without submitting.
Markup
<button class="btn" data-moey-open="#payment">Payment details</button>
<div class="popover" id="payment">
<div class="popover-header">
<h3 class="popover-title">Payment</h3>
<button class="btn-close btn-close-sm" aria-label="Close"></button>
</div>
<div class="popover-body">Visa ending 4242 · charged Nov 21, 2026.</div>
<div class="popover-footer">
<button class="btn btn-default btn-sm">Refund</button>
</div>
</div>
<a href="/users/jane" data-moey-open="#jane-card" data-moey-trigger="hover">@jane</a> <!-- a hover card -->
- Opening —
data-moey-open="#id"on any button (the same attribute that opens dialogs and menus). Clicking the button again closes it. - Closing — only on purpose: click its button again, press Esc, or use a close button inside (
.btn-close, the corner.popover-close, or anything withdata-moey-dismiss). A click elsewhere on the page doesn't close it, so you can copy text or look around. Focus goes back to the button. Opening another popover closes the first. - Close on outside click — opt in with
data-moey-close-outside="true"on the popover (or on<body>for the whole page). - Focus — moves into the popover (to an
autofocusfield if there is one), so keyboard users can reach its buttons. - Hover cards —
data-moey-trigger="hover": opens after a short pause, stays open while the pointer is on the link or the card, and also opens on keyboard focus. - Placement —
data-moey-placementon the popover:bottom(default) ·top·start·end·auto. It flips and shifts to stay on screen, and the arrow keeps pointing at the button.
| Class / attribute | What it does |
|---|---|
.popover-header · .popover-title · .popover-body · .popover-footer | The parts (all optional) |
.popover-sm · .popover-lg | 14rem · 24rem wide at most (default 18rem). Or --mo-popover-width. |
.popover-close | A round ✕ on the top-end corner, like a notification badge — added automatically when there's no other way to close (theme-* to color it) |
data-moey-close="false" | Don't add the corner ✕ |
data-moey-close-outside="true" | A click outside closes it too (off by default) |
data-moey-arrow="false" | No arrow |
pop.addEventListener('moey:open', (e) => { /* e.preventDefault() keeps it closed */ });
Moey.popover(pop, button); // open, anchored to button
Moey.popover(pop, null); // close
Profile card
More about a person, from their avatar.
<button data-moey-open="#profile">Ana Kim</button>
<div class="popover" id="profile" data-moey-placement="bottom-start">
<div class="popover-body">…</div>
<div class="popover-footer">…</div>
</div>
Share a link
A field you can copy from, without leaving the page.
<button class="btn" data-moey-open="#pvx-share"><i class="mi mi-share-2"></i>Share</button>
<div class="popover" id="pvx-share">
<div class="popover-header">
<h3 class="popover-title">Share order</h3>
<button class="btn-close btn-close-sm" aria-label="Close"></button>
</div>
<div class="popover-body flex gap-2">
<input class="form-control form-control-sm" value="https://moey.test/o/10421" readonly aria-label="Link">
<button class="btn btn-default btn-sm" onclick="navigator.clipboard?.writeText(this.previousElementSibling.value); Moey.toast('Link copied', { type: 'success' })">Copy</button>
</div>
</div>