Popover

An accessible popup anchored to a button.

API reference

Import the component and assemble its parts:

Anatomy

Root

Groups all parts of the popover. Doesn’t render its own HTML element.

PropTypeDefault
defaultOpen

boolean

false

open

boolean

undefined

onOpenChange

((open: boolean, event: Event | undefined, reason: OpenChangeReason | undefined) => void)

undefined

actionsRef

RefObject<Actions>

undefined

modal

boolean | 'trap-focus'

false

onOpenChangeComplete

((open: boolean) => void)

undefined

openOnHover

boolean

false

delay

number

300

closeDelay

number

0

children

ReactNode

undefined

Trigger

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

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-popup-open
data-pressed

Backdrop

An overlay displayed beneath the popover. Renders a <div> element.

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-closed
data-starting-style
data-ending-style

Portal

A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>.

PropTypeDefault
container

| HTMLElement
| RefObject<HTMLElement
| null>
| null

undefined

children

ReactNode

undefined

keepMounted

boolean

false

Positioner

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

PropTypeDefault
align

'center' | 'end' | 'start'

'center'

alignOffset

number | OffsetFunction

0

side

Side

'bottom'

sideOffset

number | OffsetFunction

0

arrowPadding

number

5

anchor

| Element
| RefObject<Element
| null>
| VirtualElement
| (() => Element | VirtualElement | null)
| null

undefined

collisionBoundary

Boundary

'clipping-ancestors'

collisionPadding

Padding

5

sticky

boolean

false

positionMethod

'fixed' | 'absolute'

'absolute'

trackAnchor

boolean

true

className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-closed
data-anchor-hidden
data-side
CSS Variable
Description
--anchor-height
--anchor-width
--available-height
--available-width
--transform-origin

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

PropTypeDefault
initialFocus

| RefObject<HTMLElement
| null>
| ((interactionType: InteractionType) => RefObject<HTMLElement | null>)

undefined

finalFocus

RefObject<HTMLElement | null>

undefined

className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-closed
data-instant
data-side
data-starting-style
data-ending-style

Arrow

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

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Attribute
Description
data-open
data-closed
data-uncentered
data-anchor-hidden
data-side

Title

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

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Description

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

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined

Close

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

PropTypeDefault
className

string | ((state: State) => string)

undefined

render

| ReactElement
| ((props: GenericHTMLProps, state: State) => ReactElement)

undefined