Popover
An accessible popup anchored to a button.
import { Popover } from 'base-ui-solid/popover';
import styles from './index.module.css';
export default function ExamplePopover() {
return (
<Popover.Root>
<Popover.Trigger class={styles.Button}>Notifications</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner sideOffset={8}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow} />
<Popover.Title class={styles.Title}>Notifications</Popover.Title>
<Popover.Description class={styles.Description}>
You are all caught up. Good job!
</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>
);
}
Anatomy
Import the component and assemble its parts:
import { Popover } from 'base-ui-solid/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.
import { Popover } from 'base-ui-solid/popover';
import styles from './index.module.css';
export default function ExamplePopover() {
return (
<Popover.Root>
<Popover.Trigger openOnHover class={styles.Button}>
Notifications
</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner sideOffset={8}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow} />
<Popover.Title class={styles.Title}>Notifications</Popover.Title>
<Popover.Description class={styles.Description}>
You are all caught up. Good job!
</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>
);
}
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.
The imperative methods on the handle, such as open() and close(), require a <Popover.Root> using the same handle to be mounted.
Calls made while no root is attached to the handle — before one mounts, or after it unmounts — are ignored. Each time a root mounts, it starts from fresh state: a call made while no root was attached is not replayed, and no open state carries over from a previous mount.
const demoPopover = Popover.createHandle();
<Popover.Trigger handle={demoPopover}>
Trigger
</Popover.Trigger>
<Popover.Root handle={demoPopover}>
...
</Popover.Root>
import { Popover } from 'base-ui-solid/popover';
import styles from './index.module.css';
const demoPopover = Popover.createHandle();
export default function PopoverDetachedTriggersSimpleDemo() {
return [
<Popover.Trigger class={styles.Button} handle={demoPopover}>
Notifications
</Popover.Trigger>,
<Popover.Root handle={demoPopover}>
<Popover.Portal>
<Popover.Positioner sideOffset={8}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow} />
<Popover.Title class={styles.Title}>Notifications</Popover.Title>
<Popover.Description class={styles.Description}>
You are all caught up. Good job!
</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</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}>
{(state) => (
<Popover.Portal>
<Popover.Positioner sideOffset={8}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow}>
<ArrowSvg />
</Popover.Arrow>
<Popover.Title class={styles.Title}>Popover</Popover.Title>
{state.payload !== undefined && (
<Popover.Description class={styles.Description}>
This has been opened by {state.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.
import { createSignal } from 'solid-js';
import { Popover } from 'base-ui-solid/popover';
import styles from './index.module.css';
const demoPopover = Popover.createHandle();
export default function PopoverDetachedTriggersControlledDemo() {
const [open, setOpen] = createSignal(false);
const [triggerId, setTriggerId] = createSignal<string | null>(null);
const handleOpenChange = (isOpen: boolean, eventDetails: Popover.Root.ChangeEventDetails) => {
setOpen(isOpen);
setTriggerId(eventDetails.trigger?.id ?? null);
};
return [
<div class={styles.Container}>
<Popover.Trigger class={styles.Button} handle={demoPopover} id="trigger-1">
Trigger 1
</Popover.Trigger>
<Popover.Trigger class={styles.Button} handle={demoPopover} id="trigger-2">
Trigger 2
</Popover.Trigger>
<Popover.Trigger class={styles.Button} handle={demoPopover} id="trigger-3">
Trigger 3
</Popover.Trigger>
<button
class={styles.Button}
type="button"
onClick={() => {
setTriggerId('trigger-2');
setOpen(true);
}}
>
Open programmatically
</button>
</div>,
<Popover.Root
handle={demoPopover}
open={open()}
onOpenChange={handleOpenChange}
triggerId={triggerId()}
>
<Popover.Portal>
<Popover.Positioner class={styles.Positioner} sideOffset={8}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow} />
<Popover.Title class={styles.Title}>Notifications</Popover.Title>
<Popover.Description class={styles.Description}>
You are all caught up. Good job!
</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>,
];
}
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 that indicates the new trigger’s position relative to the previous one. The value is a space-separated set of up to two tokens (one per axis) — left or right for the horizontal axis and up or down for the vertical axis (for example, right down). Match a single token with the ~= attribute selector, such as [data-activation-direction~='right'].
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.
import { Dynamic } from '@solidjs/web';
import type { Component } from 'solid-js';
import { Popover } from 'base-ui-solid/popover';
import { Avatar } from 'base-ui-solid/avatar';
import baseStyles from './index.module.css';
import styles from './opt/index.module.css';
const demoPopover = Popover.createHandle<Component>();
export default function PopoverDetachedTriggersFullDemo() {
return (
<div class={styles.Container}>
<Popover.Trigger class={baseStyles.Button} handle={demoPopover} payload={NotificationsPanel}>
Notifications
</Popover.Trigger>
<Popover.Trigger class={baseStyles.Button} handle={demoPopover} payload={ActivityPanel}>
Activity
</Popover.Trigger>
<Popover.Trigger class={baseStyles.Button} handle={demoPopover} payload={ProfilePanel}>
Profile
</Popover.Trigger>
<Popover.Root handle={demoPopover}>
{(state) => (
<Popover.Portal>
<Popover.Positioner sideOffset={8} class={styles.Positioner}>
<Popover.Popup class={styles.Popup}>
<Popover.Arrow class={styles.Arrow} />
<Popover.Viewport class={styles.Viewport}>
{state.payload !== undefined && <Dynamic component={state.payload} />}
</Popover.Viewport>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
)}
</Popover.Root>
</div>
);
}
function NotificationsPanel() {
return (
<div class={styles.Stack}>
<Popover.Title class={styles.Title}>Notifications</Popover.Title>
<Popover.Description class={styles.Description}>
You are all caught up. Good job!
</Popover.Description>
</div>
);
}
function ProfilePanel() {
return (
<div class={styles.ProfilePanel}>
<Popover.Title class={styles.Title}>Jason Eventon</Popover.Title>
<Avatar.Root class={styles.Avatar}>
<Avatar.Image
src="https://images.unsplash.com/photo-1543610892-0b1f7e6d8ac1?w=128&h=128&dpr=2&q=80"
width="48"
height="48"
class={styles.AvatarImage}
/>
</Avatar.Root>
<span class={styles.Plan}>Pro plan</span>
<div class={styles.ProfileActions}>
<a href="#">Profile settings</a>
<a href="#">Log out</a>
</div>
</div>
);
}
function ActivityPanel() {
return (
<div class={styles.Stack}>
<Popover.Title class={styles.Title}>Activity</Popover.Title>
<Popover.Description class={styles.Description}>
Nothing interesting happened recently.
</Popover.Description>
</div>
);
}
API reference
Root
Groups all parts of the popover. Doesn’t render its own HTML element.
defaultOpenbooleanfalse
open prop instead.booleanopenboolean—
booleanonOpenChangefunction—
((open: boolean, eventDetails: Popover.Root.ChangeEventDetails) => void)actionsRefRefObject<Popover.Root.Actions | null>—
unmount: Ends the closing phase of the popover after an externally controlled closing animation finishes.
Call preventUnmountOnClose() in onOpenChange first, otherwise the popover completes closing on its own.
Whether it leaves the DOM is decided by keepMounted on the portal.close: Closes the popover imperatively when called.RefObject<Popover.Root.Actions | null>defaultTriggerIdUnion—
defaultOpen prop to create an initially open popover.string | nullhandlePopover.Handle<Payload>—
Popover.Handle<Payload>modalUnionfalse
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. On touch devices, a 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.boolean | 'trap-focus'onOpenChangeCompletefunction—
((open: boolean) => void)triggerIdUnion—
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).string | nullchildrenUnion—
payload of the active trigger.JSX.Element | PayloadChildRenderFunction<Payload>Root.State
type PopoverRootState = {};Root.Actions
type PopoverRootActions = { unmount: () => void; close: () => void };Root.ChangeEventReason
type PopoverRootChangeEventReason =
| 'trigger-hover'
| 'trigger-focus'
| 'trigger-press'
| 'outside-press'
| 'escape-key'
| 'close-press'
| 'focus-out'
| 'imperative-action'
| 'none';Root.ChangeEventDetails
type PopoverRootChangeEventDetails = (
| { reason: 'trigger-hover'; event: MouseEvent }
| { reason: 'trigger-focus'; event: FocusEvent }
| { reason: 'trigger-press'; event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent }
| { reason: 'outside-press'; event: MouseEvent | PointerEvent | TouchEvent }
| { reason: 'escape-key'; event: KeyboardEvent }
| { reason: 'close-press'; event: MouseEvent | PointerEvent | KeyboardEvent }
| { reason: 'focus-out'; event: FocusEvent | KeyboardEvent }
| { reason: 'imperative-action'; event: Event }
| { reason: 'none'; event: Event }
) & {
/** Cancels Base UI from handling the event. */
cancel: () => void;
/** Allows the event to propagate in cases where Base UI will stop the propagation. */
allowPropagation: () => void;
/** Indicates whether the event has been canceled. */
isCanceled: boolean;
/** Indicates whether the event is allowed to propagate. */
isPropagationAllowed: boolean;
/** The element that triggered the event, if applicable. */
trigger: Element | undefined;
/** Prevents the popup from unmounting until the `unmount` action is called. */
preventUnmountOnClose: () => void;
};Trigger
A button that opens the popover.
Renders a <button> element.
handlePopover.Handle<Payload>—
Popover.Handle<Payload>nativeButtonbooleantrue
<button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>).booleanpayloadPayload—
PayloadopenOnHoverbooleanfalse
booleandelaynumber300
openOnHover prop.numbercloseDelaynumber0
openOnHover prop.numberidstring—
triggerId prop).stringclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-popup-open-—
-data-pressed-—
-data-disabled-—
-Attribute | Description | |
|---|---|---|
data-popup-open | Present when the corresponding popover is open. | |
data-pressed | Present when the trigger is pressed. | |
data-disabled | Present when the trigger is disabled. | |
Trigger.State
type PopoverTriggerState = {
/** Whether the trigger is currently disabled. */
disabled: boolean;
/** Whether the popover is currently open and was opened by this trigger. */
open: boolean;
};Backdrop
An overlay displayed beneath the popover.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-starting-style-—
-data-ending-style-—
-Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-starting-style | Present when the popup begins animating in. | |
data-ending-style | Present when the popup is animating out. | |
Backdrop.State
type PopoverBackdropState = {
/** Whether the popover is currently open. */
open: boolean;
/** The transition status of the component. */
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—
HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | nullclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)keepMountedbooleanfalse
booleanrenderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Portal.State
type PopoverPortalState = {};Positioner
Positions the popover against the trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
booleanalignAlign'center'
AlignalignOffsetUnion0
data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.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.number | OffsetFunctionsideSide'bottom'
SidesideOffsetUnion0
data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.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.number | OffsetFunctionarrowPaddingnumber5
numberanchorfunction—
Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | nullcollisionAvoidanceCollisionAvoidance—
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
(top and bottom, or left and right).'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 swap start and end when 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
(top before bottom, or left before right in LTR).'end': allow perpendicular fallback and try the logical end side first
(bottom before top, or right before left in LTR).'none': do not fallback to the perpendicular axis. When side is 'shift', explicitly setting align only supports 'shift' or 'none'.
If align is omitted, it defaults to 'flip'.CollisionAvoidancecollisionBoundaryBoundary'clipping-ancestors'
BoundarycollisionPaddingPadding5
Paddingstickybooleanfalse
booleanpositionMethodUnion'absolute'
position property to use.'absolute' | 'fixed'classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-anchor-hidden-—
-data-alignUnion—
'start' | 'center' | 'end'data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
CSS variables
--anchor-heightnumber—
number--anchor-widthnumber—
number--available-heightnumber—
number--available-widthnumber—
number--positioner-heightnumber—
height to this value when using CSS to animate size changes.number--positioner-widthnumber—
width to this value when using CSS to animate size changes.number--transform-originstring—
stringCSS 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. | |
--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. | |
Positioner.State
type PopoverPositionerState = {
/** Whether the popover is currently open. */
open: boolean;
/** The side of the anchor the component is placed on. */
side: Side;
/** The alignment of the component relative to the anchor. */
align: Align;
/** Whether the anchor element is hidden. */
anchorHidden: boolean;
/** Whether CSS transitions should be disabled. */
instant: string | undefined;
};Popup
A container for the popover contents.
Renders a <div> element.
initialFocusfunction—
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, or keyboard).
Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | void | HTMLElement | null)finalFocusfunction—
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, or keyboard).
Return an element to focus, true to use the default behavior, null to fall back to the default behavior, or false/undefined to do nothing.boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | void | HTMLElement | null)classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-alignUnion—
'start' | 'center' | 'end'data-instantUnion—
'click' | 'dismiss' | 'focus' | 'trigger-change'data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'data-starting-style-—
-data-ending-style-—
-Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-instant | Present if animations should be instant. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-starting-style | Present when the popup begins animating in. | |
data-ending-style | Present when the popup is animating out. | |
CSS variables
--popup-height—
--popup-width—
CSS Variable | Description | |
|---|---|---|
--popup-height | The height of the popup. | |
--popup-width | The width of the popup. | |
Popup.State
type PopoverPopupState = {
/** Whether the popover is currently open. */
open: boolean;
/** The side of the anchor the component is placed on. */
side: Side;
/** The alignment of the component relative to the anchor. */
align: Align;
/** The transition status of the component. */
transitionStatus: TransitionStatus;
/** Whether transitions should be skipped. */
instant: 'dismiss' | 'click' | 'focus' | 'trigger-change' | undefined;
};Arrow
Displays an element positioned against the popover anchor.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-uncentered-—
-data-alignUnion—
'start' | 'center' | 'end'data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-uncentered | Present when the popover arrow is uncentered. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
Arrow.State
type PopoverArrowState = {
/** Whether the popover is currently open. */
open: boolean;
/** The side of the anchor the component is placed on. */
side: Side;
/** The alignment of the component relative to the anchor. */
align: Align;
/** Whether the arrow cannot be centered on the anchor. */
uncentered: boolean;
};Title
A heading that labels the popover.
Renders an <h2> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Title.State
type PopoverTitleState = {};Description
A paragraph with additional information about the popover.
Renders a <p> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Description.State
type PopoverDescriptionState = {};Close
A button that closes the popover.
Renders a <button> element.
nativeButtonbooleantrue
<button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>).booleanclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)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
changes based on the trigger, and switching between them is animated.
Renders a <div> element.
childrenJSX.Element—
JSX.Elementclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-activation-direction` `${'left' | 'right' | ''} ${'down' | 'up' | ''}` `—
` `${'left' | 'right' | ''} ${'down' | 'up' | ''}` `data-current-—
-data-instantUnion—
'click' | 'dismiss' | 'focus' | 'trigger-change'data-previous-—
-data-transitioning-—
-Attribute | Description | |
|---|---|---|
data-activation-direction | Indicates the direction from which the popup was activated.
This can be used to create directional animations based on how the popup was triggered.
Contains space-separated values for both horizontal and vertical axes. | |
data-current | Applied to the direct child of the viewport when no transitions are present or the new content when it’s entering. | |
data-instant | Present if animations should be instant. | |
data-previous | Applied to the direct child of the viewport that contains the exiting content when transitions are present. | |
data-transitioning | Indicates that the viewport is currently transitioning between old and new content. | |
CSS variables
--popup-height—
--popup-width—
CSS Variable | Description | |
|---|---|---|
--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. | |
Viewport.State
type PopoverViewportState = {
/** The activation direction of the transitioned content. */
activationDirection: string | undefined;
/** Whether the viewport is currently transitioning between contents. */
transitioning: boolean;
/** Present if animations should be instant. */
instant: 'dismiss' | 'click' | 'focus' | 'trigger-change' | undefined;
};The Viewport is optional — reach for it only when a single popup is opened by multiple triggers, its content differs per trigger, and the switch between them is animated. When used, set width: var(--positioner-width) and height: var(--positioner-height) on the Positioner so its box is frozen to the measured size during the transition; otherwise content-driven resizing can make the popup thrash or flip to another side.
createHandle
Creates a new handle to connect a Popover.Root with detached Popover.Trigger components.
createHandle
type ReturnValue = Popover.Handle<Payload>;Handle
Controls a Popover imperatively and associates detached Popover.Trigger components with a
Popover.Root. Create one with Popover.createHandle() and pass it to the handle prop of the
root and of any triggers rendered outside of it.
The imperative methods take effect only while a root using this handle is mounted; calls made
before a root attaches (or after it unmounts) are ignored.
Opens the popover and associates it with the trigger with the given id.
This method should only be called in an event handler or an effect (not during rendering).
Closes the popover.
This method should only be called in an event handler or an effect (not during rendering).
isOpenboolean—
booleanHandle.1
function open(triggerId: string): void;Handle.2
function close(): void;