Popover
An overlay that displays additional information or options when triggered.
Anatomy
<Popover.Root>
<Popover.Trigger />
<Popover.Anchor />
<Popover.Positioner>
<Popover.Arrow>
<Popover.ArrowTip />
</Popover.Arrow>
<Popover.Content>
<Popover.Title />
<Popover.Description />
<Popover.CloseTrigger />
</Popover.Content>
</Popover.Positioner>
</Popover.Root>
Examples
Controlled
Use open and onOpenChange to control the open state.
Root Provider
Use RootProvider with the usePopover hook to access the state and methods from outside the component.
Arrow
Use Popover.Arrow and Popover.ArrowTip to render an arrow pointing to the trigger.
Placement
Set positioning to change the placement.
By default it flips to the opposite side only when there isn't room. Pass a list of placements to positioning.flip to
choose other fallbacks, such as above or below.
Close Behavior
The popover closes on blur and on esc.
- Set
closeOnInteractOutside={false}to keep it open when clicking or focusing outside. - Set
closeOnEsc={false}to keep it open on esc.
Modality
Set modal to true to make the popover:
- trap focus within its content
- block body scrolling
- disable pointer interactions outside
- hide content behind it from screen readers
modal={true} also sets portalled to true.
Anchor
Use Popover.Anchor to position the popover relative to a different element than the trigger.
Text Selection
Use positioning.getAnchorElement to anchor the popover to the current text selection.
Same Width
Use positioning.sameWidth to match the trigger's width.
Dialog Integration
Inside a dialog, you have two layering options:
-
Keep the Portal with
lazyMountandunmountOnExit: the popover unmounts when the dialog closes, so no stale DOM nodes remain. -
Remove the Portal: render the popover inline in the dialog content. Watch for z-index issues.
Nested
Each nested popover keeps its own open state and positioning.
Multiple Triggers
Pass a value to each Popover.Trigger to share one popover. It repositions to the active trigger without closing.
Guides
Available Size
Popover.Positioner exposes these CSS variables for styling Popover.Content:
/* width of the popover trigger */
--reference-width: <pixel-value>;
/* width of the available viewport */
--available-width: <pixel-value>;
/* height of the available viewport */
--available-height: <pixel-value>;
For example, to keep the content within the available height:
[data-popover-content] {
max-height: calc(var(--available-height) - 100px);
}
API Reference
Props
Root
| Prop | Default | Type |
|---|---|---|
autoFocus | true | booleanWhether to automatically set focus on the first focusable content within the popover when opened. |
closeOnEscape | true | booleanWhether to close the popover when the escape key is pressed. |
closeOnInteractOutside | true | booleanWhether to close the popover when the user clicks outside of the popover. |
defaultOpen | booleanThe initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | |
defaultTriggerValue | stringThe initial trigger value when rendered. Use when you don't need to control the trigger value. | |
finalFocusEl | () => MaybeElementElement to receive focus when the popover is closed. | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the popover. Useful for composition. | |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
initialFocusEl | () => false | HTMLElement | nullThe element to focus on when the popover is opened. Return `false` to skip moving focus, or `null` to use the default. | |
lazyMount | false | booleanWhether to enable lazy mounting |
modal | false | booleanWhether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onEscapeKeyDown | (event: KeyboardEvent) => voidFunction called when the escape key is pressed | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
onFocusOutside | (event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component | |
onInteractOutside | (event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component | |
onOpenChange | (details: OpenChangeDetails) => voidFunction invoked when the popover opens or closes | |
onPointerDownOutside | (event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component | |
onRequestDismiss | (event: LayerDismissEvent) => voidFunction called when this layer is closed due to a parent layer being closed | |
onTriggerValueChange | (details: TriggerValueChangeDetails) => voidFunction called when the trigger value changes. | |
open | booleanThe controlled open state of the popover | |
persistentElements | (() => Element | null)[]Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | |
positioning | PositioningOptionsThe user provided options used to position the popover content | |
present | booleanWhether the node is present (controlled by the user) | |
restoreFocus | true | booleanWhether to restore focus to the element that had focus before the popover was opened. |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
translations | IntlTranslationsSpecifies the localized strings that identifies the accessibility elements and their states | |
triggerValue | stringThe controlled trigger value | |
unmountOnExit | false | booleanWhether to unmount on exit. |
Anchor
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Arrow
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-popover-arrow] | <uid> |
[data-state] | "open" | "closed" |
| CSS Variable | Description |
|---|---|
--arrow-size | The size of the arrow |
--arrow-size-half | Half the size of the arrow |
--arrow-background | Use this variable to style the arrow background |
--arrow-offset | The offset position of the arrow |
ArrowTip
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
CloseTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Content
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<PopoverContentState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-popover-content] | <uid> |
[data-value] | The value of the item |
[data-state] | "open" | "closed" |
[data-expanded] | Present when expanded |
[data-placement] | The placement of the content |
[data-side] | The side of the trigger that the content is positioned on |
[data-activation-direction] | |
[data-instant] | |
[data-nested] | popover |
[data-has-nested] | popover |
| CSS Variable | Description |
|---|---|
--layer-index | The index of the dismissable in the layer stack |
--nested-layer-count | The number of nested popovers |
Description
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Indicator
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-popover-indicator] | <uid> |
[data-state] | "open" | "closed" |
Positioner
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<PopoverPositionerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-popover-positioner] | <uid> |
[data-transitioning] | |
[data-instant] | |
[data-nested] | Present when the positioner is nested within another {{widget}} |
[data-has-nested] | Present when the positioner has nested {{widget}}s |
| CSS Variable | Description |
|---|---|
--reference-width | The width of the reference element |
--reference-height | The height of the root |
--available-width | The available width in viewport |
--available-height | The available height in viewport |
--x | The x position for transform |
--y | The y position for transform |
--transform-origin | The transform origin for animations |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UsePopoverReturn | |
hideMode | 'display-none' | HideModeHow to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+. |
immediate | booleanWhether to synchronize the present change immediately or defer it to the next frame | |
lazyMount | false | booleanWhether to enable lazy mounting |
onEnterComplete | VoidFunctionFunction called when the animation ends in the open state | |
onExitComplete | VoidFunctionFunction called when the animation ends in the closed state | |
present | booleanWhether the node is present (controlled by the user) | |
skipAnimationOnMount | false | booleanWhether to allow the initial presence animation. |
unmountOnExit | false | booleanWhether to unmount on exit. |
Title
Defines the <h2> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Trigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<PopoverTriggerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
value | stringThe value that identifies this specific trigger |
| Attribute | Description |
|---|---|
[data-popover-trigger] | <uid> |
[data-placement] | The placement of the trigger |
[data-side] | The side of the trigger that the trigger is positioned on |
[data-value] | The value of the item |
[data-current] | Present when current |
[data-state] | "open" | "closed" |
Context
API
| Property | Type |
|---|---|
open | booleanWhether the popover is open |
setOpen | (open: boolean, reason?: OpenChangeReason) => voidFunction to open or close the popover |
triggerValue | string | nullThe trigger value |
setTriggerValue | (value: string | null) => voidFunction to set the trigger value |
activationDirection | PopupActivationDirection | nullWhere the current trigger sits relative to the previous one, after switching triggers while open |
getContentValues | () => string[]Returns the trigger values whose content to render: the current one, plus the previous one while it animates out after a switch. Oldest first. |
reposition | (options?: Partial<PositioningOptions>) => voidFunction to reposition the popover |
getTriggerState | (props?: TriggerProps) => TriggerStateReturns the state of a specific trigger, including whether it's the currently active one |
getPositionerState | () => PositionerStateReturns the state of the positioner |
getContentState | (props?: ContentProps) => ContentStateReturns the state of the content |
getViewportState | () => ViewportStateReturns the state of the viewport |
getTitleProps | (props?: ContentProps) => T["element"]Pass the content's `value` when there's one content per trigger |
getDescriptionProps | (props?: ContentProps) => T["element"]Pass the content's `value` when there's one content per trigger |
Accessibility
Keyboard Support
| Key | Description |
|---|---|
Space | Opens/closes the popover. |
Enter | Opens/closes the popover. |
Tab | Moves focus to the next focusable element within the content. Note: If there are no focusable elements, focus is moved to the next focusable element after the trigger. |
Shift + Tab | Moves focus to the previous focusable element within the content Note: If there are no focusable elements, focus is moved to the trigger. |
Esc | Closes the popover and moves focus to the trigger. |