Popover
An accessible popup anchored to a button.
API reference
Import the component and assemble its parts:
import { Popover } from '@base-ui-components/react/popover';
<Popover.Root> <Popover.Trigger /> <Popover.Portal> <Popover.Backdrop /> <Popover.Positioner> <Popover.Popup> <Popover.Arrow /> <Popover.Title /> <Popover.Description /> <Popover.Close /> </Popover.Popup> </Popover.Positioner> </Popover.Portal></Popover.Root>
Root
Groups all parts of the popover. Doesn’t render its own HTML element.
Prop | Type | Default | |
---|---|---|---|
defaultOpen |
|
| |
open |
|
| |
onOpenChange |
|
| |
openOnHover |
|
| |
delay |
|
| |
closeDelay |
|
|
Trigger
A button that opens the popover.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-popup-open | Present when the corresponding popover is open. | |
data-pressed | Present when the trigger is pressed. |
Backdrop
An overlay displayed beneath the popover.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
keepMounted |
|
| |
render |
|
|
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 is animating in. | |
data-ending-style | Present when the popup is animating out. |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>
.
Prop | Type | Default | |
---|---|---|---|
container |
|
| |
keepMounted |
|
|
Positioner
Positions the popover against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align |
|
| |
alignOffset |
|
| |
side |
|
| |
sideOffset |
|
| |
arrowPadding |
|
| |
anchor |
|
| |
collisionBoundary |
|
| |
collisionPadding |
|
| |
sticky |
|
| |
positionMethod |
|
| |
className |
|
| |
keepMounted |
|
| |
render |
|
|
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 | Indicates which side the popup is positioned relative to the trigger. |
CSS Variable | Description | |
---|---|---|
--anchor-height | The anchor's height. | |
--anchor-width | The anchor's width. | |
--available-height | The available height between the trigger and the edge of the viewport. | |
--available-width | The available width between the trigger and the edge of the viewport. | |
--transform-origin | The coordinates that this element is anchored to. Used for animations and transitions. |
Popup
A container for the popover contents.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
initialFocus |
|
| |
finalFocus |
|
| |
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-starting-style | Present when the popup is animating in. | |
data-ending-style | Present when the popup is animating out. |
Arrow
Displays an element positioned against the popover anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-uncentered | Present when the popover arrow is uncentered. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-side | Indicates which side the popup is positioned relative to the trigger. |
Title
A heading that labels the popover.
Renders an <h2>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Description
A paragraph with additional information about the popover.
Renders a <p>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Close
A button that closes the popover.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|