Popover
A popover displays rich content in a floating panel that’s positioned relative to a trigger element. It can be opened on click, hover, or focus.Import
Basic Usage
Sub-components
Root
Groups all parts of the popover. Doesn’t render its own HTML element. Key Props:open(boolean): Whether the popover is currently opendefaultOpen(boolean): Whether the popover is initially open (default:false)modal(boolean | ‘trap-focus’): Determines if the popover enters a modal state (default:false)true: page scroll is locked, outside interactions disabledfalse: user interaction with the rest of the document is allowed'trap-focus': focus is trapped but page scroll and outside interactions are enabled
onOpenChange((open: boolean, eventDetails) => void): Event handler called when the popover is opened or closedonOpenChangeComplete((open: boolean) => void): Event handler called after animations completehandle(PopoverHandle): A handle to associate the popover with an external triggeractionsRef(React.RefObject): A ref to imperative actions (unmount,close)
Trigger
The button that toggles the popover.Portal
Portals the popover content to a different part of the DOM.Positioner
Positions the popover relative to the trigger using Floating UI. Key Props:anchor(Element | VirtualElement): The anchor element to which the popover is positionedside(‘top’ | ‘right’ | ‘bottom’ | ‘left’): The side of the anchor to position against (default:'bottom')alignment(‘start’ | ‘center’ | ‘end’): The alignment of the popover relative to the anchor (default:'center')sideOffset(number): The distance in pixels from the anchor (default:0)alignmentOffset(number): The offset in pixels along the alignment axis (default:0)
Popup
The container for the popover content.Title
An accessible title for the popover.Description
An accessible description for the popover.Close
A button that closes the popover.Arrow
An optional arrow that points to the trigger element.Backdrop
An optional backdrop that covers the screen when the popover is open.Viewport
Defines the viewport element to which the popover is confined.Styling Example
Key Features
- Automatic positioning with collision detection
- Opens on hover, focus, or click
- Optional modal behavior with backdrop
- Arrow pointing to trigger
- Nested popover support
- Supports virtual elements as anchors
Accessibility
- Has appropriate ARIA roles
- Title and description are automatically linked via
aria-labelledbyandaria-describedby - Pressing Escape closes the popover
- Focus management with optional focus trapping
- Clicking outside closes the popover (when not modal)