Popover
OverlaysA 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.
import { Popover } from '@limerdev/zest'; 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.Examples
Basic
A panel anchored to its trigger: Escape or a click outside closes it.
<script lang="ts">
import { Field, Input, Popover } from '@limerdev/zest';
</script>
<Popover.Root>
<Popover.Trigger variant="outline">Share</Popover.Trigger>
<Popover.Content>
<Popover.Header>
<Popover.Title>Share this report</Popover.Title>
<Popover.Description>Anyone with the link can view it.</Popover.Description>
</Popover.Header>
<Field.Root>
<Field.Label class="sr-only">Link</Field.Label>
<Input value="https://zest.limer.se/r/1042" readonly />
</Field.Root>
</Popover.Content>
</Popover.Root> Sides
side and align place the panel; it flips to the other side when there is no room.
<script lang="ts">
import { Popover } from '@limerdev/zest';
type Side = 'top' | 'right' | 'bottom' | 'left';
const sides: Side[] = ['top', 'right', 'bottom', 'left'];
</script>
{#each sides as side (side)}
<Popover.Root>
<Popover.Trigger variant="outline">{side}</Popover.Trigger>
<Popover.Content {side} class="w-48">Opens on the {side}.</Popover.Content>
</Popover.Root>
{/each} A filter form
A small form in a popover, closed from code once applied.
<script lang="ts">
import { Button, Checkbox, Field, Popover } from '@limerdev/zest';
let open = $state(false);
let billable = $state(true);
let archived = $state(false);
</script>
<Popover.Root bind:open>
<Popover.Trigger variant="outline">Filters</Popover.Trigger>
<Popover.Content align="start">
<Popover.Title>Show projects</Popover.Title>
<Field.Group class="gap-3">
<Field.Root orientation="horizontal">
<Checkbox bind:checked={billable} />
<Field.Label>Billable only</Field.Label>
</Field.Root>
<Field.Root orientation="horizontal">
<Checkbox bind:checked={archived} />
<Field.Label>Include archived</Field.Label>
</Field.Root>
</Field.Group>
<Button size="sm" class="self-end" onclick={() => (open = false)}>Apply</Button>
</Popover.Content>
</Popover.Root> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Popover.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| onOpenChange | OnChangeFn<boolean> | – | A callback that is called when the popover's open state changes. |
| onOpenChangeComplete | OnChangeFn<boolean> | – | A callback that is called when the popover's open state changes and the animation is complete. |
| open bindable | boolean | false | The open state of the popover. |
Popover.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
| closeDelay | number | 300 | How long to wait before closing the popover after hover ends (ms). Only applies when openOnHover is true. |
| openDelay | number | 700 | How long to wait before opening the popover on hover (ms). Only applies when openOnHover is true. |
| openOnHover | boolean | false | Whether the popover should open when the trigger is hovered. |
| size | "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | 'default' | The height and padding, from the theme's field size; the icon sizes are square. |
| variant | "link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost" | '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. |
Popover.Close
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | 'default' | The height and padding, from the theme's field size; the icon sizes are square. |
| variant | "link" | "primary" | "secondary" | "neutral" | "error" | "outline" | "ghost" | '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. |
Popover.Portal
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | Disable portalling and render the component inline |
| to | PortalTarget | document.body | Where to portal the content to. |
Popover.Content
| Prop | Type | Default | Description |
|---|---|---|---|
| align | "start" | "center" | "end" | '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 | true | When true, overrides the side and align options to prevent collisions with the boundary edges. |
| collisionBoundary | Arrayable<Boundary> | – | A boundary element or array of elements to check for collisions against. |
| collisionPadding | number | Partial<Record<"top" | "right" | "bottom" | "left", number>> | 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" | 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" | 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 | true | Passing true will prevent the overflow of text selection outside the element, provided the element is the top layer. |
| preventScroll | boolean | 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 | 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 | false | Whether focus is trapped within the focus scope. |
| updatePositionStrategy | "always" | "optimized" | "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. |
Popover.Header
No props of its own beyond the common ones.
Popover.Title
No props of its own beyond the common ones.
Popover.Description
No props of its own beyond the common ones.