Skip to content

Popover

A click-triggered, non-modal floating panel for small chunks of contextual content and quick edits.

  • stable
  • since v0.1.0
  • 3.5 kB
  • overlay
  • popover
  • accessible

Uses role="dialog"; the trigger exposes aria-expanded; focus moves into the panel on open; Esc closes and restores focus to the trigger.

Preview
Open
tsx

PopoverContent accepts side="top" | "right" | "bottom" (default) | "left" and align="start" | "center" (default) | "end". The default sideOffset is 8 and collisionPadding is 8 — the panel flips automatically near viewport edges.

Preview
Open
tsx

Add PopoverArrow inside PopoverContent to render a pointer toward the trigger.

Preview
Open
tsx

Drive the open state externally with open / onOpenChange. Useful when the popover hosts a form whose submit closes the panel.

Preview
Open
tsx

Use PopoverAnchor to position the panel relative to an arbitrary element while keeping a separate PopoverTrigger button.

Preview
Open
tsx
PropTypeDefaultDescription
side
"top"|"right"|"bottom"|"left"
bottom
Preferred placement.
align
"center"|"start"|"end"
center
Alignment along the side.
sideOffset
number
8
Distance (px) from the anchor.
alignOffset
number
0
Offset (px) along the alignment axis.
collisionPadding
number
8
Viewport padding for collision detection.
container
HTMLElement|(() => HTMLElement)
Portal target — defaults to `document.body`.
trapFocus
boolean
true
When `false`, disable focus auto-trap into the popover on open.
initialFocus
"none"|"first"
first
Element to focus when the popover opens. Defaults to the first focusable descendant.
closeOnEscape
boolean
true
Whether `Escape` closes the popover.
closeOnOutsideClick
boolean
true
Whether outside clicks close the popover.
withArrow
boolean
true
Render a caret pointing at the trigger. The caret is side-aware and stays aimed at the trigger when the panel flips or shifts.
children
ReactNode
Body content.
  • The trigger toggles aria-expanded and references the panel via aria-controls.
  • PopoverContent carries role="dialog"; focus moves into the panel on open and returns to the trigger on close.
  • Esc closes the popover; clicking outside also closes it.
  • The popover is non-modal — the rest of the page remains interactive, but a focus scope keeps Tab cycling within the panel until it is dismissed.
  • Use PopoverClose for an explicit close button when the popover hosts a long form.
  • Use for color pickers, quick filter clusters, inline edit forms, and “more info” panels.
  • Prefer Tooltip for short text-only hover hints and Dialog when the task warrants a full modal interrupt.
  • Position with side and align; let the built-in collision detection auto-flip the surface around the viewport edge instead of hard-coding placement.
  • Pair with PopoverAnchor when the trigger and the visual anchor must be different (e.g., a global ”?” button anchoring help next to whichever field has focus).