Overview
UsePopover for contextual information or lightweight controls. Compose its portal, positioning wrapper and popup separately. Use Dropdown for menus, pickers and panels with higher-level navigation.
Usage
Uncontrolled state
UsedefaultOpen to set the initial visibility. The popover owns subsequent changes from its trigger, close controls, and dismissal interactions.
defaultOpen defaults to false, so it can be omitted. Use Title and Description to identify the popup. The trigger renders a button by default; render lets you supply a compatible element.
Placement comparison
Compare the supported sides with and without an arrow. These open examples keep each popup beside its trigger for inspection; use the Display example to try opening and dismissing a popover.Anatomy
Keep the trigger and popup insidePopover.Root. The popup can contain text, form controls, and actions.
All rendered parts support the installed Base UI native attributes, handlers, refs and element/function
render composition. Custom components must forward the supplied props and ref. Every part has a public Popover<Part>Props and Popover<Part>State type. PopoverRootProps and PopoverTriggerProps preserve payload generics. PopoverHandle, PopoverRootActions, PopoverRootChangeEventDetails and PopoverRootChangeEventReason are also exported from twenty-ui/primitives/surfaces.
Controlled state
Passopen and update it with onOpenChange to own the same popover’s visibility in React state.
onOpenChange receives the next boolean and event details, including changes requested by the trigger, close controls, Escape, and outside interaction.
Compose with buttons
Pass a Twenty UIButton through render to use it as the trigger or close control. The popover keeps its open state, keyboard behavior, and focus handling.
render composes behavior onto the supplied button. Custom wrapper components must forward the supplied props and ref to preserve that behavior.
Placement and focus
Positioner defaults to side="bottom", align="center" and sideOffset={8}. It accepts the full installed Base UI contract, including element/ref/function/virtual anchors, functional offsets, positionMethod, collisionBoundary, collisionPadding, collisionAvoidance, arrowPadding, sticky and disableAnchorTracking. DirectionProvider controls logical positioning and supplies the DOM direction. An explicit dir can override the native attribute; use the provider to change logical side placement.
Popup.initialFocus and Popup.finalFocus accept the upstream focus targets and callbacks. Root.modal retains Base UI’s nonmodal default, modal and trap-focus modes for standalone usage.
Portal destinations and theme
Setcontainer and keepMounted on Portal:
The default scoped destination preserves its CSS tokens and color scheme. An explicit destination inherits CSS from its actual DOM scope. Put it inside the intended theme scope, or supply the theme styles there. ShadowRoot targets need the library’s CSS and theme styles in that shadow tree. React theme context and provided text direction remain available across portals. This API does not expand the renderer’s permitted portal destinations.
Detached triggers and payloads
Popover.createHandle<TPayload>() connects detached triggers to a root and exposes open(triggerId), close() and isOpen. Popover.Handle is the installed upstream handle constructor. Root’s render function receives the active payload. Call imperative actions from event handlers or effects.
onOpenChange preserves reason, event, trigger, cancel() and preventUnmountOnClose(). Controlled roots retain triggerId; uncontrolled roots retain defaultTriggerId. actionsRef exposes the upstream close/unmount actions.
Migration
Movecontainer and keepMounted from Popup to Portal. Move placement, anchor and collision props to Positioner. Replace Popup.arrow with an explicit Popover.Arrow child. Popup’s native props, handlers, focus props and ref continue to target the content element. Dropdown.Content keeps its existing convenient assembly.
Inside front components, use nonmodal composition within the existing scoped portal policy. Native browser popovers/dialogs and direct app-owned modality are prohibited; use the SDK host dialog API for dialogs. Renderer portal, geometry, scrolling and dismissal capability work remains separate from this primitive API.
Props
The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.Popover.Root
A ref to imperative actions.
unmount: Ends the closing phase of the popover after an externally controlled closing animation finishes. CallpreventUnmountOnClose()inonOpenChangefirst, otherwise the popover completes closing on its own. Whether it leaves the DOM is decided bykeepMountedon the portal.close: Closes the popover imperatively when called.
Parts or a render function receiving the active trigger payload. Root renders no DOM element.
Whether the popover is initially open.To render a controlled popover, use the
open prop instead.ID of the trigger that the popover is associated with.
This is useful in conjunction with the
defaultOpen prop to create an initially open popover.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.
true modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.When modal is true, focus trapping is enabled only if <Popover.Close> is rendered
inside <Popover.Popup>. It can be visually hidden with your own CSS if needed, such as
Tailwind’s sr-only utility.When modal is 'trap-focus', render <Popover.Close> inside <Popover.Popup> so touch
screen readers can escape the popup.Receives the requested open state and Base UI event details, including reason, event, trigger, cancel() and preventUnmountOnClose().
Event handler called after any animations complete when the popover is opened or closed.
ID of the trigger that the popover is associated with.
This is useful in conjunction with the
open prop to create a controlled popover.
There’s no need to specify this prop when the popover is uncontrolled (that is, when the open prop is not set).Popover.Trigger
CSS class applied to the element, or a function that
returns a class based on the component’s state.
How long to wait before closing the popover that was opened on hover.
Specified in milliseconds.Requires the
openOnHover prop.How long to wait before the popover may be opened on hover. Specified in milliseconds.Requires the
openOnHover prop.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 PopoverRoot
triggerId prop).Whether the component renders a native
<button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (e.g. <div>).ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTriggerState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Portal
CSS class applied to the element, or a function that
returns a class based on the component’s state.
When omitted, uses the scoped theme container, then the Base UI parent portal or document body. Explicit null delays rendering until a target is supplied. Explicit elements, ShadowRoots and refs are forwarded unchanged; their DOM scope supplies CSS tokens.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPortalState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Positioner
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
data object 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.
Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null
An element to position the popup against.
By default, the popup will be positioned against the trigger.
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.
CSS class applied to the element, or a function that
returns a class based on the component’s state.
Determines how to handle collisions when positioning the popup.
side controls overflow on the preferred placement axis (top/bottom or left/right):'flip': keep the requested side when it fits; otherwise try the opposite side (topandbottom, orleftandright).'shift': never change side; keep the requested side and move the popup within the clipping boundary so it stays visible.'none': do not correct side-axis overflow.
align controls overflow on the alignment axis (start/center/end):'flip': keep side, but swapstartandendwhen the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the alignment axis to fit.'none': do not correct alignment-axis overflow.
fallbackAxisSide controls fallback behavior on the perpendicular axis when the
preferred axis cannot fit:'start': allow perpendicular fallback and try the logical start side first (topbeforebottom, orleftbeforerightin LTR).'end': allow perpendicular fallback and try the logical end side first (bottombeforetop, orrightbeforeleftin LTR).'none': do not fallback to the perpendicular axis.
side is 'shift', explicitly setting align only supports 'shift' or 'none'.
If align is omitted, it defaults to 'flip'.An element or a rectangle that delimits the area that the popup is confined to.
Whether to disable the popup from tracking any layout shift of its positioning anchor.
Ref to the positioning div. Accepts the complete Base UI anchor, collision and positioning contract.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPositionerState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Which side of the anchor element to align the popup against.
May automatically change to avoid collisions.
Distance from the anchor. Defaults to 8. Accepts a number or positioning function.
Whether to maintain the popup in the viewport after
the anchor element was scrolled out of view.
Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Popup
CSS class applied to the element, or a function that
returns a class based on the component’s state.
boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)
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,nullto fall back to the default behavior, orfalse/undefinedto do nothing.
boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)
Determines the element to focus when the popover is opened.
By default, focus moves to the first tabbable element inside the popup, except when the popover
is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.
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,nullto fall back to the default behavior, orfalse/undefinedto do nothing.
Ref to the popup div. Focus props, native attributes, handlers and render target this element.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPopupState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Arrow
CSS class applied to the element, or a function that
returns a class based on the component’s state.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverArrowState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Backdrop
CSS class applied to the element, or a function that
returns a class based on the component’s state.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverBackdropState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Title
CSS class applied to the element, or a function that
returns a class based on the component’s state.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTitleState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Description
CSS class applied to the element, or a function that
returns a class based on the component’s state.
ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverDescriptionState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Close
CSS class applied to the element, or a function that
returns a class based on the component’s state.
Whether the component renders a native
<button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>).ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverCloseState>
Allows you to replace the component’s HTML element
with a different tag, or compose it with another component.Accepts a
ReactElement or a function that returns the element to render.Style applied to the element, or a function that
returns a style object based on the component’s state.
Popover.Viewport
CSS class applied to the element, or a function that
returns a class based on the component’s state.