Overview
The Popover component displays floating content positioned relative to a trigger element. It uses Floating UI for intelligent positioning and automatically adjusts placement to stay visible within the viewport.Components
The Popover is composed of multiple subcomponents:- Popover.Root - The main container that manages popover state
- Popover.Trigger - The element that triggers the popover
- Popover.Content - The floating content container
- Popover.Arrow - Optional arrow pointing to the trigger
- Popover.Indicator - Visual indicator on the trigger (e.g., chevron)
Basic Usage
Popover.Root Props
Controls the open/closed state of the popover. Can be bound with
bind:open.When true, disables popover interactions.
Preferred placement of the popover relative to the trigger. Options:
'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'.Array of fallback placements if the preferred placement doesn’t fit.
Distance in pixels between the popover and the trigger element.
Portal destination for rendering the popover.
Optional factory function to customize popover bond creation.
Render function that receives the popover bond instance.
Popover.Trigger Props
HTML element type for the trigger.
Preset styling identifier.
as="button" (default).
Popover.Content Props
Animation function for the content. Default uses
animatePopoverContent().Popover.Arrow Props
Extends standard HTML div attributes. Automatically positions and rotates based on popover placement.Popover.Indicator Props
Extends standard HTML div attributes. Shows a visual indicator (typically a chevron) on the trigger that rotates based on open state.Animation Hooks
animatePopoverContent
Animates the popover content with scale, opacity, and position transitions based on placement.duration(number): Animation duration in seconds. Default:DURATION.quick / 1000delay(number): Animation delay in seconds. Default:0ease(string): Easing function. Default:'easeInOut'
- Scales from 0.9 to 1.0
- Moves in the direction opposite to the placement
- Uses the appropriate transform origin
Examples
With Custom Styling
Different Placements
Without Arrow
Custom Arrow
Auto-close on Click Outside
Attachment Hooks
Popover provides utility functions for common interactions:clickoutPopover
Executes a callback when clicking outside the popover.popover
Provides access to the popover bond instance.Positioning
The Popover uses Floating UI for intelligent positioning:- Automatically flips to stay in viewport
- Falls back through placement options
- Adjusts for scroll and resize
- Accounts for arrow size in positioning
Accessibility
- Trigger has appropriate
aria-*attributes - Content is portaled to appropriate layer
- Keyboard navigation supported
- Focus management when opening/closing