import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import type { Placement } from '../../utils/floating.js'; import type { PopoverVariants } from './popover.variants.js'; /** * @summary A floating panel that hangs off a trigger and closes when you look away. * @description Floating panel anchored to a trigger element. Uses the native Popover API * for top-layer rendering, light dismiss, and Escape handling. The library's built-in * positioning engine provides automatic flip, shift, and optional width syncing. * * @tag overlay * @related Tooltip * @related Menu * * @example * ```svelte * * {#snippet trigger()} * * {/snippet} * {#snippet children()} *
Popover content
* {/snippet} *
* ``` * * @example * ```svelte * * {#snippet trigger()} * * {/snippet} * {#snippet children()} *
*

Details

*

Additional context shown in a floating panel.

*
* {/snippet} *
* ``` */ export interface PopoverProps extends PopoverVariants, Omit, 'children'> { /** Popover body rendered inside the floating panel. */ children: Snippet; /** Trigger element that anchors and toggles the popover. Receives click/keyboard handlers when `autoTrigger` is true. */ trigger?: Snippet; /** External trigger element ref. Use instead of the `trigger` snippet when the trigger lives outside the Popover tree. Supports `bind:triggerElement`. */ triggerElement?: HTMLElement; /** * Where the popover appears relative to the trigger. All standard * `Placement` values (side plus optional `-start`/`-end` alignment) are * supported. * @summary Which side of the trigger the popover opens on, and how it aligns there. */ placement?: Placement; /** Gap in px between the trigger edge and the popover. */ offsetDistance?: number; /** Minimum px padding from viewport edges when the popover shifts to stay visible. */ shiftPadding?: number; /** * Match the popover width to the trigger width. Useful for * select/autocomplete patterns where the floating panel should align with * the input. * @summary Match the panel width to the trigger, as select and autocomplete patterns want. */ syncWidth?: boolean; /** Match the popover's *minimum* width to the trigger width while still letting content grow the panel beyond it. Useful for menu-style overlays where items longer than the trigger should not get truncated. Ignored when `syncWidth` is true (hard width wins). */ syncMinWidth?: boolean; /** * Render the floating panel into the browser's top layer via the native * `popover` attribute, so it cannot be clipped by `overflow: auto` ancestors. * Set to `false` when the popover is itself embedded inside another floating * surface (Dialog, Drawer, another Popover) — nested top-layer rendering * stacks unpredictably across browsers and stealing focus from the parent * surface is usually unwanted. In-flow mode positions the panel absolutely * relative to the trigger's offset parent. * @default true */ usePortal?: boolean; /** Controlled open state. Supports `bind:open`. */ open?: boolean; /** When true (default), the trigger wrapper handles click and keyboard to toggle the popover. Set to `false` to manage `open` yourself. */ autoTrigger?: boolean; /** * Render in a way that is legal inside **phrasing content** — a paragraph or a * heading. Set this when the trigger sits in flowing text, as a citation chip * does inside a markdown paragraph. * * A `