Popover
An accessible popup anchored to a button.
API reference
Import the component and place its parts the following way:
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 | |
---|---|---|---|
closeDelay | number | 0 | |
defaultOpen | boolean | false | |
delay | number | 300 | |
onOpenChange | (open, event, reason) => void | undefined | |
open | boolean | undefined | |
openOnHover | boolean | false |
Trigger
A button that opens the popover.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
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 | string | (state) => string | undefined | |
keepMounted | boolean | false | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-closed | Present when the popup is closed. | |
data-ending-style | Present when the popup is animating out. | |
data-open | Present when the popup is open. | |
data-starting-style | Present when the popup is animating in. |
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 | React.Ref | HTMLElement | null | undefined | |
keepMounted | boolean | false |
Positioner
Positions the popover against the trigger.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
align | 'start' | 'center' | 'end' | 'center' | |
alignOffset | number | 0 | |
anchor | | React.Ref | undefined | |
arrowPadding | number | 5 | |
className | string | (state) => string | undefined | |
collisionBoundary | | 'clippingAncestors' | 'clipping-ancestors' | |
collisionPadding | number | Rect | 5 | |
keepMounted | boolean | false | |
positionMethod | 'absolute' | 'fixed' | 'absolute' | |
render | | React.ReactElement | undefined | |
side | | 'bottom' | 'bottom' | |
sideOffset | number | 0 | |
sticky | boolean | false |
Attribute | Description | |
---|---|---|
data-anchor-hidden | Present when the anchor is hidden. | |
data-open | Present when the popup is open. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-unchecked | Present when the popup is closed. |
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 | |
---|---|---|---|
className | string | (state) => string | undefined | |
finalFocus | React.Ref | undefined | |
initialFocus | | React.Ref | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-closed | Present when the popup is closed. | |
data-ending-style | Present when the popup is animating out. | |
data-open | Present when the popup is open. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-starting-style | Present when the popup is animating in. |
Arrow
Displays an element positioned against the popover anchor.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-anchor-hidden | Present when the anchor is hidden. | |
data-open | Present when the popup is open. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-uncentered | Present when the tooltip arrow is uncentered. | |
data-unchecked | Present when the popup is closed. |
Title
A heading that labels the popover.
Renders an <h2>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Description
A paragraph with additional information about the popover.
Renders a <p>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |
Close
A button that closes the popover.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
render | | React.ReactElement | undefined |