Popover
A floating panel anchored to a trigger for explanatory, structured or interactive content.
Usage guidelines
- Use
Popoverfor explanatory, structured or interactive content that users must reach on touch and with assistive technology. UseTooltipfor a short visual hint on a control that already has its own action and name,Infotipwhen an information icon only opens an explanation,PreviewCardfor a non-interactive preview of a link destination, andDialogwhen the task needs a modal surface with focus containment and scroll locking. - Give the popup a
PopoverTitle; it names the dialog role the popup exposes. Add aPopoverDescriptionwhen a sentence of context helps. - Name the trigger. Visible text names a text trigger; an icon-only trigger renders
IconButtonthroughrenderand carries its ownaria-label. - Put a dedicated opener under the root as
PopoverTrigger. When the trigger has to live outside the root, connect both with a handle fromcreatePopoverHandle;handle.open(triggerId)opens the popover anchored to the registered trigger with thatid. - Several triggers can share one root. Each trigger passes its item as
payload, and the root's function child reads the payload of the trigger that opened it. - Control
openonly when another owner must observe or coordinate the open state. Analytics or cleanup alone does not need a controlled root. openOnHoveradds hover on top of click and keyboard. Content that matters still has to work for users who never hover.- Use
PopoverClosewithrenderfor actions that finish the task, such as Cancel or Send.
Anatomy
PopoverContent bundles the portal, positioner and styled popup and takes side, align and their offsets. Compose PopoverPortal, PopoverPositioner and PopoverPopup directly, with PopoverBackdrop, PopoverArrow or PopoverViewport, only when a surface needs more than those options.
Examples
Opening on hover
openOnHover on the trigger also opens the popover on hover after delay. Click, tap and keyboard still open it.
Trigger outside the root
The trigger sits outside the root and connects to it through a shared handle. The separate button calls handle.open(triggerId) to open the popover anchored to that registered trigger.
Multiple triggers
One root serves several triggers. Each trigger carries its item as payload, and the popover anchors to the trigger that opened it.
Keyboard
| Key | Action |
|---|---|
| EnterorSpace | Opens the popover from a focused trigger and moves focus to the first control inside it. |
| Tab | Moves to the next control in the popover. Past the last control, closes the popover and continues to the element after the trigger. |
| Shift+Tab | Moves to the previous control. From the first control, returns focus to the trigger and keeps the popover open. |
| Escape | Closes the popover and returns focus to the trigger. |
API reference
Popover
Groups all parts of a floating popover anchored to a trigger. Doesn't render its own HTML element.
Pass openOnHover on PopoverTrigger to also reveal on hover while keeping click and keyboard access.
| Prop | Type | Default | Details |
|---|---|---|---|
defaultOpen | boolean | false | |
open | boolean | No default | |
onOpenChange | ((open: boolean, eventDetails: BasePopover.Root.ChangeEventDetails) => void) | No default | |
onOpenChangeComplete | ((open: boolean) => void) | No default | |
actionsRef | React.RefObject<PopoverRootActions | null> | No default | |
modal | 'trap-focus' | boolean | false | |
triggerId | string | null | No default | |
defaultTriggerId | string | null | No default | |
handle | BasePopover.Handle<Payload> | No default | |
children | PayloadChildRenderFunction<Payload> | React.ReactNode | No default | |
PopoverArrow
Displays an element positioned against the popover anchor. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverArrowState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverArrowState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverArrowState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-uncentered | Present when the popover arrow is uncentered. |
PopoverBackdrop
An overlay displayed beneath the popover. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverBackdropState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverBackdropState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverBackdropState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
PopoverClose
A button that closes the popover. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverCloseState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverCloseState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverCloseState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
PopoverContent
A styled popover surface bundled with a portal and positioner. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
sideOffset | number | OffsetFunction | 8 | |
children required | React.ReactNode | No default | |
className | string | ((state: PopoverPopupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPopupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPopupState) => React.CSSProperties | undefined) | No default | |
initialFocus | boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
side | 'bottom' | 'inline-end' | 'inline-start' | 'left' | 'right' | 'top' | 'bottom' | |
align | 'center' | 'end' | 'start' | 'center' | |
alignOffset | number | OffsetFunction | 0 | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-instant | Values: Present if animations should be instant. |
| Variable | Description |
|---|---|
--popup-width | The width of the popup. |
--popup-height | The height of the popup. |
--available-width | Values: The available width between the trigger and the edge of the viewport. |
--available-height | Values: The available height between the trigger and the edge of the viewport. |
--anchor-width | Values: The anchor's width. |
--anchor-height | Values: The anchor's height. |
--transform-origin | Values: The coordinates that this element is anchored to. Used for animations and transitions. |
--positioner-width | Values: The width of the popover's positioner. It is important to set |
--positioner-height | Values: The height of the popover's positioner. It is important to set |
PopoverDescription
A paragraph with additional information about the popover. Renders a <p> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverDescriptionState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverDescriptionState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverDescriptionState) => React.CSSProperties | undefined) | No default | |
PopoverPopup
A container for the popover contents. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverPopupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPopupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPopupState) => React.CSSProperties | undefined) | No default | |
initialFocus | boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-instant | Values: Present if animations should be instant. |
| Variable | Description |
|---|---|
--popup-width | The width of the popup. |
--popup-height | The height of the popup. |
PopoverPortal
A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
keepMounted | boolean | false | |
container | HTMLElement | React.RefObject<HTMLElement | ShadowRoot | null> | ShadowRoot | null | No default | |
className | string | ((state: PopoverPortalState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPortalState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPortalState) => React.CSSProperties | undefined) | No default | |
PopoverPositioner
Positions the popover against the trigger. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
sideOffset | number | OffsetFunction | 8 | |
className | string | ((state: PopoverPositionerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPositionerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPositionerState) => React.CSSProperties | undefined) | No default | |
anchor | Element | React.RefObject<Element | null> | VirtualElement | (() => Element | VirtualElement | null) | null | No default | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
side | 'bottom' | 'inline-end' | 'inline-start' | 'left' | 'right' | 'top' | 'bottom' | |
align | 'center' | 'end' | 'start' | 'center' | |
alignOffset | number | OffsetFunction | 0 | |
collisionBoundary | Boundary | 'clipping-ancestors' | |
collisionPadding | Padding | 5 | |
sticky | boolean | false | |
arrowPadding | number | 5 | |
disableAnchorTracking | boolean | false | |
collisionAvoidance | CollisionAvoidance | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-anchor-hidden | Present when the anchor is hidden. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
| Variable | Description |
|---|---|
--available-width | Values: The available width between the trigger and the edge of the viewport. |
--available-height | Values: The available height between the trigger and the edge of the viewport. |
--anchor-width | Values: The anchor's width. |
--anchor-height | Values: The anchor's height. |
--transform-origin | Values: The coordinates that this element is anchored to. Used for animations and transitions. |
--positioner-width | Values: The width of the popover's positioner. It is important to set |
--positioner-height | Values: The height of the popover's positioner. It is important to set |
PopoverTitle
A heading that labels the popover. Renders an <h2> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverTitleState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverTitleState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverTitleState) => React.CSSProperties | undefined) | No default | |
PopoverTrigger
A button that opens the popover. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
nativeButton | boolean | true | |
id | string | No default | |
className | string | ((state: PopoverTriggerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverTriggerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverTriggerState) => React.CSSProperties | undefined) | No default | |
handle | BasePopover.Handle<Payload> | No default | |
payload | Payload | No default | |
openOnHover | boolean | false | |
delay | number | 300 | |
closeDelay | number | 0 | |
| Attribute | Description |
|---|---|
data-popup-open | Present when the corresponding popover is open. |
data-pressed | Present when the trigger is pressed. |
data-disabled | Present when the trigger is disabled. |
PopoverViewport
A viewport for displaying content transitions. This component is only required if one popup can be opened by multiple triggers, its content changes based on the trigger, and switching between them is animated. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | React.ReactNode | No default | |
className | string | ((state: PopoverViewportState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverViewportState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverViewportState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-current | Applied to the direct child of the viewport when no transitions are present or the new content when it's entering. |
data-previous | Applied to the direct child of the viewport that contains the exiting content when transitions are present. |
data-activation-direction | Values: Indicates the direction from which the popup was activated. This can be used to create directional animations based on how the popup was triggered. Contains space-separated values for both horizontal and vertical axes. |
data-transitioning | Indicates that the viewport is currently transitioning between old and new content. |
data-instant | Values: Present if animations should be instant. |
| Variable | Description |
|---|---|
--popup-width | The width of the parent popup. This variable is placed on the 'previous' container and stores the width of the popup when the previous content was rendered. It can be used to freeze the dimensions of the popup when animating between different content. |
--popup-height | The height of the parent popup. This variable is placed on the 'previous' container and stores the height of the popup when the previous content was rendered. It can be used to freeze the dimensions of the popup when animating between different content. |
createPopoverHandle
Creates a new handle to connect a Popover.Root with detached Popover.Trigger components.
Returns
BasePopover.Handle<Payload>| Member | Type | Description |
|---|---|---|
open required | (triggerId: string) => void | Opens the popover and associates it with the trigger with the given id. This method should only be called in an event handler or an effect (not during rendering). |
close required | () => void | Closes the popover. This method should only be called in an event handler or an effect (not during rendering). |
isOpen required | boolean | Whether the popover is currently open. Returns |