Skip to content

Popover

A popover inspired by Fluent UI v9. It opens a non-modal panel next to a trigger button and closes when clicking outside, pressing Esc, or clicking the trigger again. It uses the native Popover API and CSS anchor positioning, so no client-side JavaScript is shipped.

Panel placed above the trigger.
Panel placed below the trigger.
Panel placed before the trigger.
Panel placed after the trigger.
Aligned to the trigger start edge.
Centered on the trigger.
Aligned to the trigger end edge.

The default slot accepts any content, including Markdown, lists, and links.

The trigger slot replaces the button content with any markup or Astro component, such as an icon.

Icon-only trigger. label provides its accessible name.

Icon and text trigger with a custom class.

---
import Popover from 'starlight-fluent/components/Popover.astro';
import { Icon } from '@astrojs/starlight/components';
---
<Popover label="Details" position="below" align="start">
<p>Panel content</p>
</Popover>
<Popover label="Settings" triggerClass="my-trigger">
<Icon name="setting" slot="trigger" />
<p>Panel content</p>
</Popover>
Prop Type Default Description
label string Trigger text. With the trigger slot, it becomes the button aria-label.
position "above" | "below" | "before" | "after" "above" Side of the trigger where the panel opens.
align "start" | "center" | "end" "center" Alignment of the panel along the trigger edge.
class string Additional class applied to the wrapper.
triggerClass string Additional class applied to the trigger button. Use primary or minimal to change the button style (default is secondary).
Slot Description
(default) Panel content.
trigger Button content, such as text, an SVG, or an Astro component. Use <Fragment slot="trigger"> for multiple nodes.

Either label or the trigger slot is required. For icon-only triggers, set label so the button has an accessible name. When the slot contains visible text, omit label so the visible text remains the accessible name. The slot is rendered inside a <button>, so it must not contain interactive elements such as links or buttons. In MDX, leave a blank line between the slot="trigger" element and the panel content; otherwise MDX wraps both in a paragraph and the slot is not detected. Styles for triggerClass must be global (or use :global()), because the button is rendered inside the Popover component scope.

before and after follow the writing direction, so they are mirrored in right-to-left layouts. When there is not enough room, the panel flips to the opposite side. The wrapper exposes data-fluent-popover, and the panel exposes data-position and data-align.

100%