# Popover (@limerdev/zest) A panel of extra content or controls anchored to a trigger. Click or Enter opens it, Escape or a click outside closes it, and focus returns to the trigger. `Popover.Header`, `Popover.Title` and `Popover.Description` lay out its text. - Category: Overlays - Import: `import { Popover } from '@limerdev/zest'` - Bits UI: `Popover`, https://bits-ui.com/docs/components/popover - Exports: `Popover.Root`, `Popover.Trigger`, `Popover.Close`, `Popover.Portal`, `Popover.Content`, `Popover.Header`, `Popover.Title`, `Popover.Description` - Use for: Short, interactive content tied to one control: a filter form, a share link, quick settings, details behind an info button. - Don't: Content the user must deal with before going on: use `Dialog`. A plain hint on hover: use `Tooltip`. A list of actions: use `DropdownMenu`. ```svelte Share Share this report Anyone with the link can view it. ``` Props of `Popover.Root`: - `onOpenChange` (`OnChangeFn`): A callback that is called when the popover's open state changes. - `onOpenChangeComplete` (`OnChangeFn`): A callback that is called when the popover's open state changes and the animation is complete. - `open` (`boolean`, default `false`, bindable): The open state of the popover. Props of `Popover.Trigger`: - `closeDelay` (`number`, default `300`): How long to wait before closing the popover after hover ends (ms). Only applies when `openOnHover` is `true`. - `openDelay` (`number`, default `700`): How long to wait before opening the popover on hover (ms). Only applies when `openOnHover` is `true`. - `openOnHover` (`boolean`, default `false`): Whether the popover should open when the trigger is hovered. - `size` (`"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"`, default `'default'`): The height and padding, from the theme's field size; the `icon` sizes are square. - `variant` (`"link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost"`, default `'primary'`): The look, by the theme's colour roles: `primary` for the main action, `error` for deleting, `secondary`, `neutral` and `outline` for the rest, `ghost` in toolbars, `link` for a navigation that looks like text. Props of `Popover.Close`: - `size` (`"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg"`, default `'default'`): The height and padding, from the theme's field size; the `icon` sizes are square. - `variant` (`"link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost"`, default `'primary'`): The look, by the theme's colour roles: `primary` for the main action, `error` for deleting, `secondary`, `neutral` and `outline` for the rest, `ghost` in toolbars, `link` for a navigation that looks like text. Props of `Popover.Portal`: - `disabled` (`boolean`, default `false`): Disable portalling and render the component inline - `to` (`PortalTarget`, default `document.body`): Where to portal the content to. Props of `Popover.Content`: - `align` (`"start" | "center" | "end"`, default `'center'`): The preferred alignment of the anchor to render against when open. This may change when collisions occur. - `alignOffset` (`number`): An offset in pixels from the "start" or "end" alignment options. - `arrowPadding` (`number`): This describes the padding between the arrow and the edges of the floating element. If your floating element has border-radius, this will prevent it from overflowing the corners. - `avoidCollisions` (`boolean`, default `true`): When `true`, overrides the `side` and `align` options to prevent collisions with the boundary edges. - `collisionBoundary` (`Arrayable`): A boundary element or array of elements to check for collisions against. - `collisionPadding` (`number | Partial>`, default `8`): The amount in pixels of virtual padding around the viewport edges to check for overflow which will cause a collision. - `customAnchor` (`string | HTMLElement | Measurable | null`): Use an element other than the trigger to anchor the content to. If provided, the content will be anchored to the provided element instead of the trigger. You can pass a selector string or an HTMLElement. - `dir` (`"ltr" | "rtl"`): The text direction of the content. - `escapeKeydownBehavior` (`"close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore"`, default `close`): Escape behavior type. `close`: Closes the element immediately. `defer-otherwise-close`: Delegates the action to its parent component that has an escape keydown handler. If no parent is found, it closes the element. `defer-otherwise-ignore`: Delegates the action to the parent element. If no parent is found, nothing is done. `ignore`: Prevents the element from closing and also blocks the parent element from closing in response to an escape key press. - `forceMount` (`boolean`): Whether to force mount the component. - `hideWhenDetached` (`boolean`) - `interactOutsideBehavior` (`"close" | "defer-otherwise-close" | "defer-otherwise-ignore" | "ignore"`, default `close`): Interact outside behavior type. `close`: Closes the element immediately. `defer-otherwise-close`: Delegates the action to the parent element. If no parent is found, it closes the element. `defer-otherwise-ignore`: Delegates the action to the parent element. If no parent is found, nothing is done. `ignore`: Prevents the element from closing and also blocks the parent element from closing in response to an outside interaction. - `onCloseAutoFocus` (`EventCallback`): Event handler called when auto-focusing on close. Can be prevented. - `onEscapeKeydown` (`((e: KeyboardEvent) => void)`): Callback fired when escape is pressed. - `onFocusOutside` (`((event: FocusEvent) => void)`): Callback fired when focus leaves the dismissible layer. - `onInteractOutside` (`InteractOutsideEventHandler`): Callback fired when an outside interaction event completes, which is either a `pointerup`, `mouseup`, or `touchend` event, depending on the user's input device. - `onOpenAutoFocus` (`EventCallback`): Event handler called when auto-focusing on open. Can be prevented. - `portalProps` (`PortalProps`): Props for the portal the content renders in: `to` (the element to render in, the body by default) and `disabled` (render in place). - `preventOverflowTextSelection` (`boolean`, default `true`): Passing `true` will prevent the overflow of text selection outside the element, provided the element is the top layer. - `preventScroll` (`boolean`, default `true`): Whether to prevent scrolling the body when the content is open. Whether to prevent body scrolling when the content is open. - `side` (`"top" | "right" | "bottom" | "left"`): The preferred side of the anchor to render against when open. Will be reversed when collisions occur. - `sideOffset` (`number`, default `4`): The distance in pixels from the anchor to the floating element. - `sticky` (`"partial" | "always"`) - `strategy` (`"absolute" | "fixed"`): The positioning strategy to use for the floating element. - `trapFocus` (`boolean`, default `false`): Whether focus is trapped within the focus scope. - `updatePositionStrategy` (`"always" | "optimized"`, default `"optimized"`): "optimized" will only update the position when necessary, while "always" will update the position on each animation frame, which is useful if the floating content is following something like a mouse cursor. Example: Basic A panel anchored to its trigger: Escape or a click outside closes it. ```svelte Share Share this report Anyone with the link can view it. Link ``` Example: Sides side and align place the panel; it flips to the other side when there is no room. ```svelte {#each sides as side (side)} {side} Opens on the {side}. {/each} ``` Example: A filter form A small form in a popover, closed from code once applied. ```svelte Filters Show projects Billable only Include archived ```