Skip to main content

Overview

Popover displays floating content anchored to a trigger element. It includes smart positioning with collision detection, automatic focus management, and keyboard navigation.

Basic usage

Components

Popover (Root)

The root component that manages popover state and positioning context.
boolean
Controls the open state of the popover (controlled mode).
boolean
The initial open state in uncontrolled mode.
(open: boolean) => void
Callback fired when the open state changes.
boolean
default:"false"
Whether the popover is modal (blocks interaction with content behind it).
boolean
Whether to open the popover on hover instead of click.

Popover.Trigger

A button that opens the popover when activated.
boolean
When true, merges props with the immediate child element instead of rendering a button.

Popover.Content

The popover content container with positioning logic.
'top' | 'right' | 'bottom' | 'left'
default:"'bottom'"
The preferred side of the trigger to render the popover.
'start' | 'center' | 'end'
default:"'center'"
The preferred alignment against the trigger.
number
default:"4"
The distance in pixels from the trigger.
number
The offset in pixels from the aligned edge.
number
default:"3"
The padding in pixels from the viewport edges for collision detection.
'partial' | 'always'
The sticky behavior of the popover during scrolling.
boolean
Whether to hide the popover when the trigger is fully occluded.
number | React.RefObject
The element that receives focus when the popover opens.
React.RefObject
The element that receives focus when the popover closes.
string
Additional CSS classes for the popover content.

Popover.Close

A button that closes the popover when clicked.
boolean
When true, merges props with the immediate child element instead of rendering a button.

Usage examples

Positioned popover

With custom offset

Hover trigger

Controlled popover

With close button

Positioning

The Popover uses smart positioning logic:
  1. Preferred side: Set via the side prop
  2. Collision detection: Automatically flips to the opposite side if there isn’t enough space
  3. Alignment: Control via the align prop (start, center, end)
  4. Offsets: Fine-tune position with sideOffset and alignOffset
All positioning is handled automatically with viewport boundary detection:

Accessibility features

  • Keyboard navigation: Arrow keys to navigate, Enter/Space to activate
  • ESC to close: Press Escape to close the popover
  • Focus management: Automatic focus handling with initialFocus and finalFocus props
  • Focus return: Focus returns to the trigger when closed
  • ARIA attributes: Proper ARIA relationships between trigger and content
  • Screen reader support: Announces popover state changes

Trigger patterns

The Popover.Trigger component supports two usage patterns:
  1. Default button: Renders a button when no children provided or asChild is false
  2. Custom trigger: Use asChild to merge popover functionality with your component