Skip to content

Popover ​

A floating interactive panel anchored to a trigger element. Unlike a tooltip, a popover can contain any interactive content (forms, menus, rich text) via slots.

Placement ​

Placement is a preference: the panel flips or shifts when space is limited. When a panel fits within the viewport but neither side of its trigger has enough room, it can overlap the trigger rather than extend off-screen.

Full width

Trigger Modes ​

Full width

Rich Content ​

The content slot accepts any HTML: forms, cards, images, custom layouts.

Full width

Controlled Open State ​

Use open as the controlled state and update it from open-change. Use default-open only to initialize an uncontrolled popover.

html
<ore-popover id="my-popover" placement="bottom">
  <ore-button id="trigger-btn">Open</ore-button>
  <div slot="content" style="padding:1rem;">
    <p>Controlled popover content.</p>
    <ore-button id="close-btn" size="sm" variant="ghost">Close</ore-button>
  </div>
</ore-popover>

<script type="module">
  import '@vielzeug/refine/button';
  import '@vielzeug/refine/popover';

  const popover = document.getElementById('my-popover');
  document.getElementById('trigger-btn').addEventListener('click', () => {
    popover.setAttribute('open', '');
  });
  document.getElementById('close-btn').addEventListener('click', () => {
    popover.removeAttribute('open');
  });
</script>

Disabled ​

Full width

Listening to Events ​

html
<ore-popover id="pop">
  <ore-button>Toggle</ore-button>
  <div slot="content" style="padding:0.75rem;">Panel content</div>
</ore-popover>

<script type="module">
  import '@vielzeug/refine/button';
  import '@vielzeug/refine/popover';

  const pop = document.getElementById('pop');
  pop.addEventListener('open-change', (e) => console.log('popover open:', e.detail.open, e.detail.reason));
</script>

API Reference ​

Attributes ​

AttributeTypeDefaultDescription
placement'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end''bottom'Preferred placement
triggerstring'click'Trigger mode(s): click, hover, focus, comma-separated
openbooleanN/AControlled open state
default-openbooleanfalseInitial state when open is not provided
offsetnumber8Gap in pixels between trigger and panel
disabledbooleanfalsePrevent the popover from opening
labelstringN/Aaria-label for the panel

Slots ​

SlotDescription
(default)The trigger element the panel is anchored to
contentContent rendered inside the floating panel

Events ​

EventDetailDescription
open-change{ open: boolean, reason: string }Fired whenever the panel opens or closes

CSS Custom Properties ​

PropertyDescription
--popover-min-widthMinimum width of the floating panel
--popover-max-widthMaximum width of the floating panel
--popover-overflowPanel overflow behavior; use visible for nested top-layer controls

Accessibility ​

The popover component follows WAI-ARIA best practices. Pressing Escape closes the popover and returns focus to the trigger. Tab moves focus through interactive elements inside the panel.

The panel uses role="dialog" when the label attribute is set, giving screen readers a concise title on open. The trigger element receives aria-expanded and aria-controls reflecting the current open state. Always provide a label attribute to give the panel an accessible name.

When the trigger mode includes click or focus, focus moves into the panel on open and returns to the trigger element on close.

  • Tooltip: lightweight non-interactive floating label
  • Menu: dropdown menu with keyboard navigation