Popover
An accessible popup anchored to a button.
View as MarkdownAnatomy
Import the component and assemble its parts:
import { Popover } from '@base-ui/react/popover';
<Popover.Root>
<Popover.Trigger />
<Popover.Portal>
<Popover.Backdrop />
<Popover.Positioner>
<Popover.Popup>
<Popover.Arrow />
<Popover.Viewport>
<Popover.Title />
<Popover.Description />
<Popover.Close />
</Popover.Viewport>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>Examples
Opening on hover
This example shows how you can configure the popover to open on hover using the openOnHover prop.
You can use the delay prop to specify how long to wait (in milliseconds) before the popover opens on hover.
Detached triggers
A popover can be controlled by a trigger located either inside or outside the <Popover.Root> component.
For simple, one-off interactions, place the <Popover.Trigger> inside <Popover.Root>, as shown in the example at the top of this page.
However, if defining the popover’s content next to its trigger is not practical, you can use a detached trigger.
This involves placing the <Popover.Trigger> outside of <Popover.Root> and linking them with a handle created by the Popover.createHandle() function.
const demoPopover = Popover.createHandle();
<Popover.Trigger handle={demoPopover}>
Trigger
</Popover.Trigger>
<Popover.Root handle={demoPopover}>
...
</Popover.Root>Multiple triggers
A single popover can be opened by multiple trigger elements.
You can achieve this by using the same handle for several detached triggers, or by placing multiple <Popover.Trigger> components inside a single <Popover.Root>.
<Popover.Root>
<Popover.Trigger>Trigger 1</Popover.Trigger>
<Popover.Trigger>Trigger 2</Popover.Trigger>
...
</Popover.Root>const demoPopover = Popover.createHandle();
<Popover.Trigger handle={demoPopover}>
Trigger 1
</Popover.Trigger>
<Popover.Trigger handle={demoPopover}>
Trigger 2
</Popover.Trigger>
<Popover.Root handle={demoPopover}>
...
</Popover.Root>The popover can render different content depending on which trigger opened it.
This is achieved by passing a payload to the <Popover.Trigger> and using the function-as-a-child pattern in <Popover.Root>.
The payload can be strongly typed by providing a type argument to the createHandle() function:
const demoPopover = Popover.createHandle<{ text: string }>();
<Popover.Trigger handle={demoPopover} payload={{ text: 'Trigger 1' }}>
Trigger 1
</Popover.Trigger>
<Popover.Trigger handle={demoPopover} payload={{ text: 'Trigger 2' }}>
Trigger 2
</Popover.Trigger>
<Popover.Root handle={demoPopover}>
{({ payload }) => (
<Popover.Portal>
<Popover.Positioner sideOffset={8}>
<Popover.Popup className={styles.Popup}>
<Popover.Arrow className={styles.Arrow}>
<ArrowSvg />
</Popover.Arrow>
<Popover.Title className={styles.Title}>Popover</Popover.Title>
{payload !== undefined && (
<Popover.Description className={styles.Description}>
This has been opened by {payload.text}
</Popover.Description>
)}
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
)}
</Popover.Root>Controlled mode with multiple triggers
You can control the popover’s open state externally using the open and onOpenChange props on <Popover.Root>.
This allows you to manage the popover’s visibility based on your application’s state.
When using multiple triggers, you have to manage which trigger is active with the triggerId prop on <Popover.Root> and the id prop on each <Popover.Trigger>.
Note that there is no separate onTriggerIdChange prop.
Instead, the onOpenChange callback receives an additional argument, eventDetails, which contains the trigger element that initiated the state change.
Animating the Popover
You can animate a popover as it moves between different trigger elements. This includes animating its position, size, and content.
Position and Size
To animate the popover’s position, apply CSS transitions to the left, right, top, and bottom properties of the Positioner part.
To animate its size, transition the width and height of the Popup part.
Content
The popover also supports content transitions. This is useful when different triggers display different content within the same popover.
To enable content animations, wrap the content in the <Popover.Viewport> part.
This part provides features to create direction-aware animations.
It renders a div with a data-activation-direction attribute (left, right, up, or down) that indicates the new trigger’s position relative to the previous one.
Inside the <Popover.Viewport>, the content is further wrapped in divs with data attributes to help with styling:
data-current: The currently visible content when no transitions are present or the incoming content.data-previous: The outgoing content during a transition.
You can use these attributes to style the enter and exit animations.
API reference
Root
Groups all parts of the popover. Doesn’t render its own HTML element.
defaultOpenbooleanfalse
boolean- Name
- Description
Whether the popover is initially open.
To render a controlled popover, use the
openprop instead.- Type
boolean | undefined- Default
false
openboolean—
boolean- Name
- Description
Whether the popover is currently open.
- Type
boolean | undefined
onOpenChangefunction—
function- Name
- Description
Event handler called when the popover is opened or closed.
- Type
| (( open: boolean, eventDetails: Popover.Root.ChangeEventDetails, ) => void) | undefined
actionsRef| React.RefObject<Popover.Root.Actions
| null>—
| React.RefObject<Popover.Root.Actions
| null>- Name
- Description
A ref to imperative actions.
unmount: When specified, the popover will not be unmounted when closed. Instead, theunmountfunction must be called to unmount the popover manually. Useful when the popover’s animation is controlled by an external library.close: Closes the dialog imperatively when called.
- Type
React.RefObject<Popover.Root.Actions | null> | undefined
defaultTriggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
defaultOpenprop to create an initially open popover.- Type
string | null | undefined
handlePopover.Handle<Payload>—
Popover.Handle<Payload>- Name
- Description
A handle to associate the popover with a trigger. If specified, allows external triggers to control the popover’s open state.
- Type
Popover.Handle<Payload> | undefined
modalboolean | 'trap-focus'false
boolean | 'trap-focus'- Name
- Description
Determines if the popover enters a modal state when open.
true: user interaction is limited to the popover: document page scroll is locked, and pointer interactions on outside elements are disabled.false: user interaction with the rest of the document is allowed.'trap-focus': focus is trapped inside the popover, but document page scroll is not locked and pointer interactions outside of it remain enabled.
- Type
boolean | 'trap-focus' | undefined- Default
false
onOpenChangeCompletefunction—
function- Description
Event handler called after any animations complete when the popover is opened or closed.
- Type
((open: boolean) => void) | undefined
triggerIdstring | null—
string | null- Name
- Description
ID of the trigger that the popover is associated with. This is useful in conjunction with the
openprop to create a controlled popover. There’s no need to specify this prop when the popover is uncontrolled (that is, when theopenprop is not set).- Type
string | null | undefined
children| React.ReactNode
| PayloadChildRenderFunction<Payload>—
| React.ReactNode
| PayloadChildRenderFunction<Payload>- Name
- Description
The content of the popover. This can be a regular React node or a render function that receives the
payloadof the active trigger.- Type
React.ReactNode | ((arg: { payload: unknown | undefined }) => ReactNode)<Payload> | undefined
Additional Types
Popover.Root.Props
Re-Export of Root props as PopoverRootProps
Popover.Root.State
type PopoverRootState = {};Popover.Root.Actions
type PopoverRootActions = { unmount: () => void; close: () => void };Popover.Root.ChangeEventReason
type PopoverRootChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'escape-key'
| 'close-press'
| 'focus-out'
| 'imperative-action'
| 'none';Popover.Root.ChangeEventDetails
type PopoverRootChangeEventDetails =
| {
reason: 'trigger-hover';
event: MouseEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-focus';
event: FocusEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'trigger-press';
event:
| MouseEvent
| PointerEvent
| TouchEvent
| KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'outside-press';
event: MouseEvent | PointerEvent | TouchEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'escape-key';
event: KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'close-press';
event: MouseEvent | PointerEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'focus-out';
event: FocusEvent | KeyboardEvent;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'imperative-action';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}
| {
reason: 'none';
event: Event;
cancel: () => void;
allowPropagation: () => void;
isCanceled: boolean;
isPropagationAllowed: boolean;
trigger: Element | undefined;
preventUnmountOnClose: () => void;
}Trigger
A button that opens the popover.
Renders a <button> element.
handlePopover.Handle<Payload>—
Popover.Handle<Payload>- Name
- Description
A handle to associate the trigger with a popover.
- Type
Popover.Handle<Payload> | undefined
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
payloadPayload—
Payload- Name
- Description
A payload to pass to the popover when it is opened.
- Type
Payload | undefined
openOnHoverbooleanfalse
boolean- Name
- Description
Whether the popover should also open when the trigger is hovered.
- Type
boolean | undefined- Default
false
delaynumber300
number- Name
- Description
How long to wait before the popover may be opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
300
closeDelaynumber0
number- Name
- Description
How long to wait before closing the popover that was opened on hover. Specified in milliseconds.
Requires the
openOnHoverprop.- Type
number | undefined- Default
0
idstring—
string- Name
- Description
ID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the popover in controlled mode (with the Popover.Root
triggerIdprop).- Type
string | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Trigger.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Description
Style applied to the element, or a function that returns a style object based on the component’s state.
- Type
| React.CSSProperties | (( state: Popover.Trigger.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Trigger.State, ) => ReactElement) | undefined
data-popup-open
data-pressed
Additional Types
Popover.Trigger.Props
Re-Export of Trigger props as PopoverTriggerProps
Popover.Trigger.State
type PopoverTriggerState = { disabled: boolean; open: boolean };Backdrop
An overlay displayed beneath the popover.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Backdrop.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Backdrop.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Backdrop.State, ) => ReactElement) | undefined
data-open
data-closed
data-starting-style
data-ending-style
Additional Types
Popover.Backdrop.Props
Re-Export of Backdrop props as PopoverBackdropProps
Popover.Backdrop.State
type PopoverBackdropState = { open: boolean; transitionStatus: TransitionStatus };Portal
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.
containerUnion—
Union- Name
- Description
A parent element to render the portal element into.
- Type
| HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Portal.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Portal.State, ) => React.CSSProperties | undefined) | undefined
keepMountedbooleanfalse
boolean- Name
- Description
Whether to keep the portal mounted in the DOM while the popup is hidden.
- Type
boolean | undefined- Default
false
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Portal.State, ) => ReactElement) | undefined
Additional Types
Popover.Portal.Props
Re-Export of Portal props as PopoverPortalProps
Popover.Portal.State
type PopoverPortalState = {};Positioner
Positions the popover against the trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
boolean- Description
Whether to disable the popup from tracking any layout shift of its positioning anchor.
- Type
boolean | undefined- Default
false
alignAlign'center'
Align- Name
- Description
How to align the popup relative to the specified side.
- Type
'start' | 'center' | 'end' | undefined- Default
'center'
alignOffsetnumber | OffsetFunction0
number | OffsetFunction- Name
- Description
Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.
- Type
| number | ((data: { side: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; anchor: { width: number; height: number }; positioner: { width: number; height: number }; }) => number) | undefined- Default
0- Example
<Positioner alignOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.width : anchor.height; }} />
sideSide'bottom'
Side- Name
- Description
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.
- Type
| 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | undefined- Default
'bottom'
sideOffsetnumber | OffsetFunction0
number | OffsetFunction- Name
- Description
Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.
The function takes a
dataobject parameter with the following properties:data.anchor: the dimensions of the anchor element with propertieswidthandheight.data.positioner: the dimensions of the positioner element with propertieswidthandheight.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.
- Type
| number | ((data: { side: | 'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'; align: 'start' | 'center' | 'end'; anchor: { width: number; height: number }; positioner: { width: number; height: number }; }) => number) | undefined- Default
0- Example
<Positioner sideOffset={({ side, align, anchor, positioner }) => { return side === 'top' || side === 'bottom' ? anchor.height : anchor.width; }} />
arrowPaddingnumber5
number- Name
- Description
Minimum distance to maintain between the arrow and the edges of the popup.
Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
- Type
number | undefined- Default
5
anchorUnion—
Union- Name
- Description
An element to position the popup against. By default, the popup will be positioned against the trigger.
- Type
| Element | VirtualElement | React.RefObject<Element | null> | (() => Element | VirtualElement | null) | null | undefined
collisionAvoidanceCollisionAvoidance—
CollisionAvoidance- Description
Determines how to handle collisions when positioning the popup.
- Type
CollisionAvoidance | undefined- Example
<Positioner collisionAvoidance={{ side: 'shift', align: 'shift', fallbackAxisSide: 'none', }} />
collisionBoundaryBoundary'clipping-ancestors'
Boundary- Description
An element or a rectangle that delimits the area that the popup is confined to.
- Type
Boundary | undefined- Default
'clipping-ancestors'
collisionPaddingPadding5
Padding- Name
- Description
Additional space to maintain from the edge of the collision boundary.
- Type
Padding | undefined- Default
5
stickybooleanfalse
boolean- Name
- Description
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.
- Type
boolean | undefined- Default
false
positionMethod'absolute' | 'fixed''absolute'
'absolute' | 'fixed'- Name
- Description
Determines which CSS
positionproperty to use.- Type
'absolute' | 'fixed' | undefined- Default
'absolute'
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Popover.Positioner.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Positioner.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Positioner.State, ) => ReactElement) | undefined
data-open
data-closed
data-anchor-hidden
data-align
data-side
--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.
--positioner-height
The height of the popover’s positioner.
It is important to set height to this value when using CSS to animate size changes.
--positioner-width
The width of the popover’s positioner.
It is important to set width to this value when using CSS to animate size changes.
--transform-origin
The coordinates that this element is anchored to. Used for animations and transitions.
Additional Types
Popover.Positioner.Props
Re-Export of Positioner props as PopoverPositionerProps
Popover.Positioner.State
type PopoverPositionerState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
anchorHidden: boolean;
instant: string | undefined;
}Popup
A container for the popover contents.
Renders a <div> element.
initialFocusUnion—
Union- Name
- Description
Determines the element to focus when the popover is opened.
false: Do not move focus.true: Move focus based on the default behavior (first tabbable element or popup).RefObject: Move focus to the ref element.function: Called with the interaction type (mouse,touch,pen, orkeyboard). Return an element to focus,trueto use the default behavior, orfalse/undefinedto do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( openType: 'mouse' | 'touch' | 'pen' | 'keyboard' | '', ) => boolean | void | HTMLElement | null) | undefined
finalFocusUnion—
Union- Name
- Description
Determines the element to focus when the popover is closed.
false: Do not move focus.true: Move focus based on the default behavior (trigger or previously focused element).RefObject: Move focus to the ref element.function: Called with the interaction type (mouse,touch,pen, orkeyboard). Return an element to focus,trueto use the default behavior, orfalse/undefinedto do nothing.
- Type
| boolean | React.RefObject<HTMLElement | null> | (( closeType: | 'mouse' | 'touch' | 'pen' | 'keyboard' | '', ) => boolean | void | HTMLElement | null) | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Popup.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Popup.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Popup.State, ) => ReactElement) | undefined
data-open
data-closed
data-align
data-instant
data-side
data-starting-style
data-ending-style
--popup-height
The height of the popup.
--popup-width
The width of the popup.
Additional Types
Popover.Popup.Props
Re-Export of Popup props as PopoverPopupProps
Popover.Popup.State
type PopoverPopupState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
transitionStatus: TransitionStatus;
instant: 'dismiss' | 'click' | undefined;
}Arrow
Displays an element positioned against the popover anchor.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Arrow.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Arrow.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Arrow.State, ) => ReactElement) | undefined
data-open
data-closed
data-uncentered
data-align
data-side
Additional Types
Popover.Arrow.Props
Re-Export of Arrow props as PopoverArrowProps
Popover.Arrow.State
type PopoverArrowState = {
open: boolean;
side:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'inline-end'
| 'inline-start';
align: 'start' | 'center' | 'end';
uncentered: boolean;
}Title
A heading that labels the popover.
Renders an <h2> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Title.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Title.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Title.State, ) => ReactElement) | undefined
Additional Types
Popover.Title.Props
Re-Export of Title props as PopoverTitleProps
Popover.Title.State
type PopoverTitleState = {};Description
A paragraph with additional information about the popover.
Renders a <p> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | (( state: Popover.Description.State, ) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Description.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Description.State, ) => ReactElement) | undefined
Additional Types
Popover.Description.Props
Re-Export of Description props as PopoverDescriptionProps
Popover.Description.State
type PopoverDescriptionState = {};Close
A button that closes the popover.
Renders a <button> element.
nativeButtonbooleantrue
boolean- Name
- Description
Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (for example,<div>).- Type
boolean | undefined- Default
true
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Close.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Close.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Close.State, ) => ReactElement) | undefined
Additional Types
Popover.Close.Props
Re-Export of Close props as PopoverCloseProps
Popover.Close.State
type PopoverCloseState = {};Viewport
A viewport for displaying content transitions.
This component is only required if one popup can be opened by multiple triggers, its content change based on the trigger
and switching between them is animated.
Renders a <div> element.
childrenReact.ReactNode—
React.ReactNode- Name
- Description
The content to render inside the transition container.
- Type
React.ReactNode | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Popover.Viewport.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Popover.Viewport.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Popover.Viewport.State, ) => ReactElement) | undefined
data-activation-direction
data-current
data-instant
data-previous
data-transitioning
--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.
--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.
Additional Types
Popover.Viewport.Props
Re-Export of Viewport props as PopoverViewportProps
Popover.Viewport.State
type PopoverViewportState = {
activationDirection: string | undefined;
transitioning: boolean;
instant: 'dismiss' | 'click' | undefined;
};createHandle
Creates a new handle to connect a Popover.Root with detached Popover.Trigger components.
Return value
Popover.Handle<Payload>Handle
Properties
isOpenbooleanreadonly
boolean- Name
- Description
Indicates whether the popover is currently open.
- Type
boolean- Modifiers
readonly
Methods
open(triggerId)void
- Name
- Description
Opens the popover and associates it with the trigger with the given id. The trigger must be a Popover.Trigger component with this handle passed as a prop.
- Parameters
triggerId—stringID of the trigger to associate with the popover.
- Returns
void
close()void
- Name
- Description
Closes the popover.
- Returns
void