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.
Examples
Section titled “Examples”Alignment
Section titled “Alignment”Rich content
Section titled “Rich content”Popover title
Section titled “Popover title”The default slot accepts any content, including Markdown, lists, and links.
Custom trigger
Section titled “Custom trigger”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>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.