Component API

<popover-panel>

Open live example

Generic anchored popover shell: a floating card positioned relative to its
nearest position: relative ancestor (place it next to its trigger button
inside such a wrapper), as opposed to slide-panel's fixed screen-edge
drawer. Closes on outside click or Escape. Header chrome and close button
match slide-panel's API (heading, panel-close) so either can be
swapped in for the other with no consumer-side changes beyond the wrapper.

Set centered to render as a screen-centered modal with a translucent
backdrop instead of the default anchored placement.

Install

import "@f-ewald/components/popover-panel.js";

Usage

<div style="position: relative; display: inline-block;">
  <button id="new-task-btn">New task</button>
  <popover-panel heading="New task">
    Popover body content goes here.
  </popover-panel>
</div>
<script type="module">
  const popover = document.querySelector("popover-panel");
  document.querySelector("#new-task-btn").addEventListener("click", () => (popover.open = true));
  popover.addEventListener("panel-close", () => (popover.open = false));
</script>

Attributes / properties

PropertyAttributeTypeDefaultDescription
openopenbooleanfalseWhether the popover is currently visible.
headingheadingstring""Title text shown in the popover header.
centeredcenteredbooleanfalseRender as a screen-centered modal with a backdrop instead of anchored placement.

Events

EventDescription
panel-closeUser clicked the close (✕) button, pressed Escape, or clicked outside/the backdrop.

Slots

SlotDescription
(default)Popover body content.
titleOverrides the plain heading text with custom markup.
actionsExtra header controls (e.g. an icon+label link) rendered between the title and the close button.

CSS custom properties

Custom property
--ui-border
--ui-focus-ring
--ui-font
--ui-font-size-lg
--ui-font-weight-semibold
--ui-line-height-tight
--ui-overlay
--ui-radius
--ui-radius-sm
--ui-shadow-lg
--ui-surface
--ui-surface-muted
--ui-text
--ui-text-muted