Skip to content

Popover

A floating panel anchored to a trigger for explanatory, structured or interactive content.

hero.tsx

Usage guidelines

  • Use Popover for explanatory, structured or interactive content that users must reach on touch and with assistive technology. Use Tooltip for a short visual hint on a control that already has its own action and name, Infotip when an information icon only opens an explanation, PreviewCard for a non-interactive preview of a link destination, and Dialog when 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 a PopoverDescription when a sentence of context helps.
  • Name the trigger. Visible text names a text trigger; an icon-only trigger renders IconButton through render and carries its own aria-label.
  • Put a dedicated opener under the root as PopoverTrigger. When the trigger has to live outside the root, connect both with a handle from createPopoverHandle; handle.open(triggerId) opens the popover anchored to the registered trigger with that id.
  • 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 open only when another owner must observe or coordinate the open state. Analytics or cleanup alone does not need a controlled root.
  • openOnHover adds hover on top of click and keyboard. Content that matters still has to work for users who never hover.
  • Use PopoverClose with render for actions that finish the task, such as Cancel or Send.

Anatomy

tsx
tsx

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.

open-on-hover.tsx

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.

detached-trigger.tsx

Multiple triggers

One root serves several triggers. Each trigger carries its item as payload, and the popover anchors to the trigger that opened it.

multiple-triggers.tsx

Keyboard

KeyAction
EnterorSpaceOpens the popover from a focused trigger and moves focus to the first control inside it.
TabMoves to the next control in the popover. Past the last control, closes the popover and continues to the element after the trigger.
Shift+TabMoves to the previous control. From the first control, returns focus to the trigger and keeps the popover open.
EscapeCloses 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.

Base UI Popover.Root docs

PopoverArrow

Displays an element positioned against the popover anchor. Renders a <div> element.

Base UI Popover.Arrow docs

Data attributes
AttributeDescription
data-open

Present when the popup is open.

data-closed

Present when the popup is closed.

data-side

Values: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

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.

Base UI Popover.Backdrop docs

Data attributes
AttributeDescription
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.

Base UI Popover.Close docs

PopoverContent

A styled popover surface bundled with a portal and positioner. Renders a <div> element.

Base UI Popover.Popup docs

Props
PropTypeDefaultDetails
sideOffsetnumber | OffsetFunction8
children requiredReact.ReactNodeNo default
Base UI Popover.Popup docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

data-instant

Values: 'click' | 'dismiss' | 'focus' | 'trigger-change'

Present if animations should be instant.

CSS variables
VariableDescription
--popup-width

The width of the popup.

--popup-height

The height of the popup.

--available-width

Values: number

The available width between the trigger and the edge of the viewport.

--available-height

Values: number

The available height between the trigger and the edge of the viewport.

--anchor-width

Values: number

The anchor's width.

--anchor-height

Values: number

The anchor's height.

--transform-origin

Values: string

The coordinates that this element is anchored to. Used for animations and transitions.

--positioner-width

Values: number

The width of the popover's positioner. It is important to set width to this value when using CSS to animate size changes.

--positioner-height

Values: number

The height of the popover's positioner. It is important to set height to this value when using CSS to animate size changes.

PopoverDescription

A paragraph with additional information about the popover. Renders a <p> element.

Base UI Popover.Description docs

PopoverPopup

A container for the popover contents. Renders a <div> element.

Base UI Popover.Popup docs

Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

data-instant

Values: 'click' | 'dismiss' | 'focus' | 'trigger-change'

Present if animations should be instant.

CSS variables
VariableDescription
--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.

Base UI Popover.Portal docs

PopoverPositioner

Positions the popover against the trigger. Renders a <div> element.

Base UI Popover.Positioner docs

Props
PropTypeDefaultDetails
sideOffsetnumber | OffsetFunction8
Base UI Popover.Positioner docs
Data attributes
AttributeDescription
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: 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

Indicates which side the popup is positioned relative to the trigger.

data-align

Values: 'start' | 'center' | 'end'

Indicates how the popup is aligned relative to specified side.

CSS variables
VariableDescription
--available-width

Values: number

The available width between the trigger and the edge of the viewport.

--available-height

Values: number

The available height between the trigger and the edge of the viewport.

--anchor-width

Values: number

The anchor's width.

--anchor-height

Values: number

The anchor's height.

--transform-origin

Values: string

The coordinates that this element is anchored to. Used for animations and transitions.

--positioner-width

Values: number

The width of the popover's positioner. It is important to set width to this value when using CSS to animate size changes.

--positioner-height

Values: number

The height of the popover's positioner. It is important to set height to this value when using CSS to animate size changes.

PopoverTitle

A heading that labels the popover. Renders an <h2> element.

Base UI Popover.Title docs

PopoverTrigger

A button that opens the popover. Renders a <button> element.

Base UI Popover.Trigger docs

Data attributes
AttributeDescription
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.

Base UI Popover.Viewport docs

Data attributes
AttributeDescription
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: `${'left' | 'right' | ''} ${'down' | 'up' | ''}`

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: 'click' | 'dismiss' | 'focus' | 'trigger-change'

Present if animations should be instant.

CSS variables
VariableDescription
--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>
Return properties
MemberTypeDescription
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 requiredboolean

Whether the popover is currently open. Returns false while no root is attached to the handle.