Popover

The Popover component is a small overlay that displays additional content or information when triggered by a user action, such as clicking or hovering over an element. It provides contextual information or interactive elements without navigating away from the current page. This component enhances user experience by delivering relevant content in a non-intrusive, easily accessible manner.

Arrow

Content

onClose

() => void

call a function when popover closed

store
Required

UsePopover | UsePopoverHover

Popover

accessibleWhenDisabled

Boolean

Indicates whether the element should be focusable even when it is [`disabled`](https://ariakit.org/reference/focusable#disabled). This is important when discoverability is a concern. For example: > A toolbar in an editor contains a set of special smart paste functions that are disabled when the clipboard is empty or when the function is not applicable to the current content of the clipboard. It could be helpful to keep the disabled buttons focusable if the ability to discover their functionality is primarily via their presence on the toolbar. Learn more on [Focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols). Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)

alwaysVisible

Boolean | undefined = false

Determines whether the content element should remain visible even when the [`open`](https://ariakit.org/reference/disclosure-provider#open) state is `false`. If this prop is set to `true`, the `hidden` prop and the `display: none` style will not be applied, unless explicitly set otherwise. This prop is particularly useful when using third-party animation libraries such as Framer Motion or React Spring, where the element needs to be visible for exit animations to work. Live examples: - [Dialog with Framer Motion](https://ariakit.org/examples/dialog-framer-motion) - [Menu with Framer Motion](https://ariakit.org/examples/menu-framer-motion) - [Tooltip with Framer Motion](https://ariakit.org/examples/tooltip-framer-motion) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details)

arrowPadding

number | undefined = 4

The minimum padding between the arrow and the popover corner.

autoFocus

Boolean | undefined = false

Automatically focuses the element upon mounting, similar to the native `autoFocus` prop. This addresses an issue where the element with the native `autoFocus` attribute might receive focus before React effects are executed. The `autoFocus` prop can also be used with [Focusable](https://ariakit.org/components/focusable) elements within a [Dialog](https://ariakit.org/components/dialog) component, establishing the initial focus as the dialog opens. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Dialog with React Router](https://ariakit.org/examples/dialog-react-router) - [Nested Dialog](https://ariakit.org/examples/dialog-nested)

autoFocusOnHide

false | true | (arg: HTMLElement) => boolean | undefined = true

Determines whether an element outside of the dialog will be focused when the dialog is hidden if another element hasn't been focused in the action of hiding the dialog (for example, by clicking or tabbing into another tabbable element outside of the dialog). By default, this is usually the disclosure element. The [`finalFocus`](https://ariakit.org/reference/dialog#finalfocus) prop can be used to define a different element to be focused. Live examples: - [Dialog with Next.js App Router](https://ariakit.org/examples/dialog-next-router) - [Sliding menu](https://ariakit.org/examples/menu-slide)

autoFocusOnShow

false | true | (arg: HTMLElement) => boolean | undefined = true

Determines whether an element inside the dialog will receive focus when the dialog is shown. By default, this is usually the first tabbable element in the dialog or the dialog itself. The [`initialFocus`](https://ariakit.org/reference/dialog#initialfocus) prop can be used to set a different element to receive focus. Live examples: - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Sliding Menu](https://ariakit.org/examples/menu-slide) - [Selection Popover](https://ariakit.org/examples/popover-selection)

backdrop

false | true | "p" | "div" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "big" | "caption" | "cite" | "code" | "dd" | "dfn" | "dt" | "em" | "figcaption" | "figure" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "i" | "kbd" | "keygen" | "main" | "mark" | "menu" | "menuitem" | "nav" | "noindex" | "noscript" | "picture" | "rp" | "rt" | "ruby" | "s" | "samp" | "section" | "small" | "span" | "strong" | "sub" | "summary" | "sup" | "u" | "var" | "wbr" | "webview" | ReactElement<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }, string | JSXElementConstructor<...>> | ComponentClass<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }, any> | FunctionComponent<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }>

Determines whether there will be a backdrop behind the dialog. On modal dialogs, this is `true` by default. Besides a `boolean`, this prop can also be a React component or JSX element that will be rendered as the backdrop. **Note**: If a custom component is used, it must [accept ref and spread all props to its underlying DOM element](https://ariakit.org/guide/composition#custom-components-must-be-open-for-extension), the same way a native element would. Live examples: - [Animated Dialog](https://ariakit.org/examples/dialog-animated) - [Dialog with scrollable backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable) - [Dialog with Framer Motion](https://ariakit.org/examples/dialog-framer-motion) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu) - [Nested Dialog](https://ariakit.org/examples/dialog-nested) - [Dialog with Next.js App Router](https://ariakit.org/examples/dialog-next-router) @example ```jsx <Dialog backdrop={<div className="backdrop" />} /> ```

disabled

Boolean | undefined = false

Determines if the element is disabled. This sets the `aria-disabled` attribute accordingly, enabling support for all elements, including those that don't support the native `disabled` attribute. This feature can be combined with the [`accessibleWhenDisabled`](https://ariakit.org/reference/focusable#accessiblewhendisabled) prop to make disabled elements still accessible via keyboard. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Submenu](https://ariakit.org/examples/menu-nested) - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Context Menu](https://ariakit.org/examples/menu-context-menu)

finalFocus

HTMLElement | RefObject<HTMLElement>

Determines the element that will receive focus once the dialog is closed, provided that no other element has been focused while the dialog was being hidden (e.g., by clicking or tabbing into another tabbable element outside of the dialog). - If [`autoFocusOnHide`](https://ariakit.org/reference/dialog#autofocusonhide) is set to `false`, this prop will have no effect. - If left unset, the element that was focused before the dialog was opened will be focused again.

fitViewport

Boolean | undefined = false

Whether the popover should fit the viewport. If this is set to true, the popover wrapper will have `maxWidth` and `maxHeight` set to the viewport size. This will be exposed to CSS as [`--popover-available-width`](https://ariakit.org/guide/styling#--popover-available-width) and [`--popover-available-height`](https://ariakit.org/guide/styling#--popover-available-height). Live examples: - [Textarea with inline Combobox](https://ariakit.org/examples/combobox-textarea) - [Menubar](https://ariakit.org/components/menubar)

fixed

Boolean | undefined = false

Whether the popover has `position: fixed` or not.

flip

string | false | true | undefined = true

Controls the behavior of the popover when it overflows the viewport: - If a `boolean`, specifies whether the popover should flip to the opposite side when it overflows. - If a `string`, indicates the preferred fallback placements when it overflows. The placements must be spaced-delimited, e.g. "top left". Live examples: - [Sliding Menu](https://ariakit.org/examples/menu-slide) - [Menubar](https://ariakit.org/components/menubar)

focusable

Boolean | undefined = true

Determines if [Focusable](https://ariakit.org/components/focusable) features should be active on non-native focusable elements. **Note**: This prop only turns off the additional features provided by the [`Focusable`](https://ariakit.org/reference/focusable) component. Non-native focusable elements will lose their focusability entirely. However, native focusable elements will retain their inherent focusability, but without added features such as improved [`autoFocus`](https://ariakit.org/reference/focusable#autofocus), [`accessibleWhenDisabled`](https://ariakit.org/reference/focusable#accessiblewhendisabled), [`onFocusVisible`](https://ariakit.org/reference/focusable#onfocusvisible), etc.

getAnchorRect

(anchor: HTMLElement) => AnchorRect

Function that returns the anchor element's DOMRect. If this is explicitly passed, it will override the anchor `getBoundingClientRect` method. Live examples: - [Textarea with inline combobox](https://ariakit.org/examples/combobox-textarea) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Context menu](https://ariakit.org/examples/menu-context-menu) - [Selection Popover](https://ariakit.org/examples/popover-selection)

getPersistentElements

() => Iterable<Element>

When a dialog is open, the elements outside of it are disabled to prevent interaction if the dialog is [`modal`](https://ariakit.org/reference/dialog#modal). For non-modal dialogs, interacting with elements outside the dialog prompts it to close. This function allows you to return an iterable collection of elements that will be considered as part of the dialog, thus excluding them from this behavior. **Note**: The elements returned by this function must exist in the DOM when the dialog opens. Live examples: - [Dialog with React-Toastify](https://ariakit.org/examples/dialog-react-toastify)

gutter

number | undefined = 0

The distance between the popover and the anchor element. Live examples: - [Combobox filtering](https://ariakit.org/examples/combobox-filtering) - [Form with Select](https://ariakit.org/examples/form-select) - [Hovercard with keyboard support](https://ariakit.org/examples/hovercard-disclosure) - [MenuItemRadio](https://ariakit.org/examples/menu-item-radio) - [Submenu](https://ariakit.org/examples/menu-nested) - [Toolbar with Select](https://ariakit.org/examples/toolbar-select)

hideOnEscape

false | true | (arg: KeyboardEvent | React.KeyboardEvent<Element>) => boolean | undefined = true

Determines if the dialog will hide when the user presses the Escape key. This prop can be either a boolean or a function that accepts an event as an argument and returns a boolean. The event object represents the keydown event that initiated the hide action, which could be either a native keyboard event or a React synthetic event. **Note**: When placing Ariakit dialogs inside third-party dialogs, using `event.stopPropagation()` within this function will stop the event from reaching the third-party dialog, closing only the Ariakit dialog.

hideOnInteractOutside

false | true | (arg: Event | SyntheticEvent<Element, Event>) => boolean | undefined = true

Determines if the dialog should hide when the user clicks or focuses on an element outside the dialog. This prop can be either a boolean or a function that takes an event as an argument and returns a boolean. The event object represents the event that triggered the action, which could be a native event or a React synthetic event of various types. Live examples: - [Selection Popover](https://ariakit.org/examples/popover-selection)

initialFocus

HTMLElement | RefObject<HTMLElement>

Specifies the element that will receive focus when the dialog is first opened. It can be an `HTMLElement` or a `React.RefObject` with an `HTMLElement`. If [`autoFocusOnShow`](https://ariakit.org/reference/dialog#autofocusonshow) is set to `false`, this prop will have no effect. If left unset, the dialog will attempt to determine the initial focus element in the following order: 1. A [Focusable](https://ariakit.org/components/focusable) element with an [`autoFocus`](https://ariakit.org/reference/focusable#autofocus) prop. 2. The first tabbable element inside the dialog. 3. The first focusable element inside the dialog. 4. The dialog element itself.

modal

Boolean | undefined = true

Determines whether the dialog is modal. Modal dialogs have distinct states and behaviors: - The [`portal`](https://ariakit.org/reference/dialog#portal) and [`preventBodyScroll`](https://ariakit.org/reference/dialog#preventbodyscroll) props are set to `true`. They can still be manually set to `false`. - When using the [`Heading`](https://ariakit.org/reference/heading) or [`DialogHeading`](https://ariakit.org/reference/dialog-heading) components within the dialog, their level will be reset so they start with `h1`. - A visually hidden dismiss button will be rendered if the [`DialogDismiss`](https://ariakit.org/reference/dialog-dismiss) component hasn't been used. This allows screen reader users to close the dialog. - When the dialog is open, element tree outside it will be inert. Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details) - [Form with Select](https://ariakit.org/examples/form-select) - [Context menu](https://ariakit.org/examples/menu-context-menu) - [Responsive Popover](https://ariakit.org/examples/popover-responsive)

onClose

() => void

call a function when popover closed

onFocusVisible

BivariantCallback<(event: SyntheticEvent<HTMLElement, Event>) => void>

Custom event handler invoked when the element gains focus through keyboard interaction or a key press occurs while the element is in focus. This is the programmatic equivalent of the [`data-focus-visible`](https://ariakit.org/guide/styling#data-focus-visible) attribute. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Custom Checkbox](https://ariakit.org/examples/checkbox-custom)

open

Boolean

Controls the open state of the dialog. This is similar to the [`open`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/open) attribute on native dialog elements. Live examples: - [Dialog with scrollable backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details) - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)

overflowPadding

number | undefined = 8

The minimum padding between the popover and the viewport edge. This will be exposed to CSS as [`--popover-overflow-padding`](https://ariakit.org/guide/styling#--popover-overflow-padding). Live examples: - [Sliding Menu](https://ariakit.org/examples/menu-slide)

overlap

Boolean | undefined = false

Whether the popover can overlap the anchor element when it overflows. Live examples: - [Menubar](https://ariakit.org/components/menubar) - [Submenu with Combobox](https://ariakit.org/examples/menu-nested-combobox)

portal

Boolean | undefined = true

Determines whether the element should be rendered as a React Portal. Live examples: - [Combobox with integrated filter](https://ariakit.org/examples/combobox-filtering-integrated) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu) - [Hovercard with keyboard support](https://ariakit.org/examples/hovercard-disclosure) - [Menubar](https://ariakit.org/components/menubar) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Animated Select](https://ariakit.org/examples/select-animated)

portalElement

HTMLElement | (element: HTMLElement) => HTMLElement

An HTML element or a memoized callback function that returns an HTML element to be used as the portal element. By default, the portal element will be a `div` element appended to the `document.body`. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) @example ```jsx const [portal, setPortal] = useState(null); <Portal portalElement={portal} /> <div ref={setPortal} /> ``` @example ```jsx const getPortalElement = useCallback(() => { const div = document.createElement("div"); const portalRoot = document.getElementById("portal-root"); portalRoot.appendChild(div); return div; }, []); <Portal portalElement={getPortalElement} /> ```

portalRef

RefCallback<HTMLElement> | MutableRefObject<HTMLElement>

`portalRef` is similar to `ref` but is scoped to the portal node. It's useful when you need to be informed when the portal element is appended to the DOM or removed from the DOM. Live examples: - [Form with Select](https://ariakit.org/examples/form-select) @example ```jsx const [portalElement, setPortalElement] = useState(null); <Portal portalRef={setPortalElement} /> ```

preserveTabOrder

Boolean | undefined = false

When enabled, `preserveTabOrder` will keep the DOM element's tab order the same as the order in which the underlying [`Portal`](https://ariakit.org/reference/portal) component was mounted in the React tree. If the [`preserveTabOrderAnchor`](https://ariakit.org/reference/portal#preservetaborderanchor) prop is provided, the tab order will be preserved relative to that element.

preserveTabOrderAnchor

Element

An anchor element for maintaining the tab order when [`preserveTabOrder`](https://ariakit.org/reference/portal#preservetaborder) prop is enabled. The tab order will be kept relative to this element. By default, the tab order is kept relative to the original location in the React tree where the underlying [`Portal`](https://ariakit.org/reference/portal) component was mounted. @example ```jsx {18-20} const [anchor, setAnchor] = useState(null); <button ref={setAnchor}>Order 0</button> <button>Order 2</button> // Rendered at the end of the document. <Portal> <button>Order 5</button> </Portal> // Rendered at the end of the document, but the tab order is preserved. <Portal preserveTabOrder> <button>Order 3</button> </Portal> // Rendered at the end of the document, but the tab order is preserved // relative to the anchor element. <Portal preserveTabOrder preserveTabOrderAnchor={anchor}> <button>Order 1</button> </Portal> <button>Order 4</button> ```

preventBodyScroll

Boolean

Determines whether the body scrolling will be prevented when the dialog is shown. This is automatically set to `true` when the dialog is [`modal`](https://ariakit.org/reference/dialog#modal). You can disable this prop if you want to implement your own logic.

render

ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>

Allows the component to be rendered as a different HTML element or React component. The value can be a React element or a function that takes in the original component props and gives back a React element with the props merged. Check out the [Composition](https://ariakit.org/guide/composition) guide for more details.

sameWidth

Boolean | undefined = false

Whether the popover should have the same width as the anchor element. This will be exposed to CSS as [`--popover-anchor-width`](https://ariakit.org/guide/styling#--popover-anchor-width).

shift

number | undefined = 0

The skidding of the popover along the anchor element. Can be set to negative values to make the popover shift to the opposite side. Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Submenu](https://ariakit.org/examples/menu-nested) - [Menubar](https://ariakit.org/components/menubar)

slide

Boolean | undefined = true

Whether the popover should slide when it overflows.

store
Required

PopoverStore & Pick<UsePopoverProps, "withCloseButton">

Object returned by the [`usePopoverStore`](https://ariakit.org/reference/use-popover-store) hook. If not provided, the closest [`PopoverProvider`](https://ariakit.org/reference/popover-provider) component's context will be used.

unmountOnHide

Boolean | undefined = false

When set to `true`, the content element will be unmounted and removed from the DOM when it's hidden. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Combobox with integrated filter](https://ariakit.org/examples/combobox-filtering-integrated) - [Textarea with inline Combobox](https://ariakit.org/examples/combobox-textarea) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Animated Select](https://ariakit.org/examples/select-animated) - [Multi-Select](https://ariakit.org/examples/select-multiple)

updatePosition

(props: { updatePosition: () => Promise<void>; }) => void | Promise<void>

A callback that will be called when the popover needs to calculate its position. This will override the internal `updatePosition` function. The original `updatePosition` function will be passed as an argument, so it can be called inside the callback to apply the default behavior. Live examples: - [Responsive Popover](https://ariakit.org/examples/popover-responsive)

wrapElement

WrapElement

wrapperProps

HTMLAttributes<HTMLDivElement>

Props that will be passed to the popover wrapper element. This element will be used to position the popover. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Sliding Menu](https://ariakit.org/examples/menu-slide)

PopoverHover

accessibleWhenDisabled

Boolean

Indicates whether the element should be focusable even when it is [`disabled`](https://ariakit.org/reference/focusable#disabled). This is important when discoverability is a concern. For example: > A toolbar in an editor contains a set of special smart paste functions that are disabled when the clipboard is empty or when the function is not applicable to the current content of the clipboard. It could be helpful to keep the disabled buttons focusable if the ability to discover their functionality is primarily via their presence on the toolbar. Learn more on [Focusability of disabled controls](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols). Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs)

alwaysVisible

Boolean | undefined = false

Determines whether the content element should remain visible even when the [`open`](https://ariakit.org/reference/disclosure-provider#open) state is `false`. If this prop is set to `true`, the `hidden` prop and the `display: none` style will not be applied, unless explicitly set otherwise. This prop is particularly useful when using third-party animation libraries such as Framer Motion or React Spring, where the element needs to be visible for exit animations to work. Live examples: - [Dialog with Framer Motion](https://ariakit.org/examples/dialog-framer-motion) - [Menu with Framer Motion](https://ariakit.org/examples/menu-framer-motion) - [Tooltip with Framer Motion](https://ariakit.org/examples/tooltip-framer-motion) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details)

arrowPadding

number | undefined = 4

The minimum padding between the arrow and the popover corner.

autoFocus

Boolean | undefined = false

Automatically focuses the element upon mounting, similar to the native `autoFocus` prop. This addresses an issue where the element with the native `autoFocus` attribute might receive focus before React effects are executed. The `autoFocus` prop can also be used with [Focusable](https://ariakit.org/components/focusable) elements within a [Dialog](https://ariakit.org/components/dialog) component, establishing the initial focus as the dialog opens. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Dialog with React Router](https://ariakit.org/examples/dialog-react-router) - [Nested Dialog](https://ariakit.org/examples/dialog-nested)

autoFocusOnHide

false | true | (arg: HTMLElement) => boolean | undefined = true

Determines whether an element outside of the dialog will be focused when the dialog is hidden if another element hasn't been focused in the action of hiding the dialog (for example, by clicking or tabbing into another tabbable element outside of the dialog). By default, this is usually the disclosure element. The [`finalFocus`](https://ariakit.org/reference/dialog#finalfocus) prop can be used to define a different element to be focused. Live examples: - [Dialog with Next.js App Router](https://ariakit.org/examples/dialog-next-router) - [Sliding menu](https://ariakit.org/examples/menu-slide)

autoFocusOnShow

false | true | (arg: HTMLElement) => boolean | undefined = true

Determines whether an element inside the dialog will receive focus when the dialog is shown. By default, this is usually the first tabbable element in the dialog or the dialog itself. The [`initialFocus`](https://ariakit.org/reference/dialog#initialfocus) prop can be used to set a different element to receive focus. Live examples: - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Sliding Menu](https://ariakit.org/examples/menu-slide) - [Selection Popover](https://ariakit.org/examples/popover-selection)

backdrop

false | true | "p" | "div" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "big" | "caption" | "cite" | "code" | "dd" | "dfn" | "dt" | "em" | "figcaption" | "figure" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "i" | "kbd" | "keygen" | "main" | "mark" | "menu" | "menuitem" | "nav" | "noindex" | "noscript" | "picture" | "rp" | "rt" | "ruby" | "s" | "samp" | "section" | "small" | "span" | "strong" | "sub" | "summary" | "sup" | "u" | "var" | "wbr" | "webview" | ReactElement<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }, string | JSXElementConstructor<...>> | ComponentClass<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }, any> | FunctionComponent<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>> & { ...; }>

Determines whether there will be a backdrop behind the dialog. On modal dialogs, this is `true` by default. Besides a `boolean`, this prop can also be a React component or JSX element that will be rendered as the backdrop. **Note**: If a custom component is used, it must [accept ref and spread all props to its underlying DOM element](https://ariakit.org/guide/composition#custom-components-must-be-open-for-extension), the same way a native element would. Live examples: - [Animated Dialog](https://ariakit.org/examples/dialog-animated) - [Dialog with scrollable backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable) - [Dialog with Framer Motion](https://ariakit.org/examples/dialog-framer-motion) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu) - [Nested Dialog](https://ariakit.org/examples/dialog-nested) - [Dialog with Next.js App Router](https://ariakit.org/examples/dialog-next-router) @example ```jsx <Dialog backdrop={<div className="backdrop" />} /> ```

disablePointerEventsOnApproach

false | true | (arg: MouseEvent) => boolean | undefined = true

Determines if the pointer events outside of the popover and its anchor element should be disabled during _hover intent_, that is, when the mouse is moving toward the popover. This is required as these external events may trigger focus on other elements and close the popover while the user is attempting to hover over it. This can be either a boolean or a callback receiving the mouse event happening during hover intent. The callback should return a boolean.

disabled

Boolean | undefined = false

Determines if the element is disabled. This sets the `aria-disabled` attribute accordingly, enabling support for all elements, including those that don't support the native `disabled` attribute. This feature can be combined with the [`accessibleWhenDisabled`](https://ariakit.org/reference/focusable#accessiblewhendisabled) prop to make disabled elements still accessible via keyboard. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Submenu](https://ariakit.org/examples/menu-nested) - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Context Menu](https://ariakit.org/examples/menu-context-menu)

finalFocus

HTMLElement | RefObject<HTMLElement>

Determines the element that will receive focus once the dialog is closed, provided that no other element has been focused while the dialog was being hidden (e.g., by clicking or tabbing into another tabbable element outside of the dialog). - If [`autoFocusOnHide`](https://ariakit.org/reference/dialog#autofocusonhide) is set to `false`, this prop will have no effect. - If left unset, the element that was focused before the dialog was opened will be focused again.

fitViewport

Boolean | undefined = false

Whether the popover should fit the viewport. If this is set to true, the popover wrapper will have `maxWidth` and `maxHeight` set to the viewport size. This will be exposed to CSS as [`--popover-available-width`](https://ariakit.org/guide/styling#--popover-available-width) and [`--popover-available-height`](https://ariakit.org/guide/styling#--popover-available-height). Live examples: - [Textarea with inline Combobox](https://ariakit.org/examples/combobox-textarea) - [Menubar](https://ariakit.org/components/menubar)

fixed

Boolean | undefined = false

Whether the popover has `position: fixed` or not.

flip

string | false | true | undefined = true

Controls the behavior of the popover when it overflows the viewport: - If a `boolean`, specifies whether the popover should flip to the opposite side when it overflows. - If a `string`, indicates the preferred fallback placements when it overflows. The placements must be spaced-delimited, e.g. "top left". Live examples: - [Sliding Menu](https://ariakit.org/examples/menu-slide) - [Menubar](https://ariakit.org/components/menubar)

focusable

Boolean | undefined = true

Determines if [Focusable](https://ariakit.org/components/focusable) features should be active on non-native focusable elements. **Note**: This prop only turns off the additional features provided by the [`Focusable`](https://ariakit.org/reference/focusable) component. Non-native focusable elements will lose their focusability entirely. However, native focusable elements will retain their inherent focusability, but without added features such as improved [`autoFocus`](https://ariakit.org/reference/focusable#autofocus), [`accessibleWhenDisabled`](https://ariakit.org/reference/focusable#accessiblewhendisabled), [`onFocusVisible`](https://ariakit.org/reference/focusable#onfocusvisible), etc.

getAnchorRect

(anchor: HTMLElement) => AnchorRect

Function that returns the anchor element's DOMRect. If this is explicitly passed, it will override the anchor `getBoundingClientRect` method. Live examples: - [Textarea with inline combobox](https://ariakit.org/examples/combobox-textarea) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Context menu](https://ariakit.org/examples/menu-context-menu) - [Selection Popover](https://ariakit.org/examples/popover-selection)

getPersistentElements

() => Iterable<Element>

When a dialog is open, the elements outside of it are disabled to prevent interaction if the dialog is [`modal`](https://ariakit.org/reference/dialog#modal). For non-modal dialogs, interacting with elements outside the dialog prompts it to close. This function allows you to return an iterable collection of elements that will be considered as part of the dialog, thus excluding them from this behavior. **Note**: The elements returned by this function must exist in the DOM when the dialog opens. Live examples: - [Dialog with React-Toastify](https://ariakit.org/examples/dialog-react-toastify)

gutter

number | undefined = 0

The distance between the popover and the anchor element. Live examples: - [Combobox filtering](https://ariakit.org/examples/combobox-filtering) - [Form with Select](https://ariakit.org/examples/form-select) - [Hovercard with keyboard support](https://ariakit.org/examples/hovercard-disclosure) - [MenuItemRadio](https://ariakit.org/examples/menu-item-radio) - [Submenu](https://ariakit.org/examples/menu-nested) - [Toolbar with Select](https://ariakit.org/examples/toolbar-select)

hideOnEscape

false | true | (arg: KeyboardEvent | React.KeyboardEvent<Element>) => boolean | undefined = true

Determines if the dialog will hide when the user presses the Escape key. This prop can be either a boolean or a function that accepts an event as an argument and returns a boolean. The event object represents the keydown event that initiated the hide action, which could be either a native keyboard event or a React synthetic event. **Note**: When placing Ariakit dialogs inside third-party dialogs, using `event.stopPropagation()` within this function will stop the event from reaching the third-party dialog, closing only the Ariakit dialog.

hideOnHoverOutside

false | true | (arg: MouseEvent) => boolean | undefined = true

Determines whether the popover should hide when the mouse leaves the popover or the anchor element and there's no _hover intent_, meaning, the mouse isn't moving toward the popover. This can be either a boolean or a callback receiving the mouse move event that initiated the behavior. The callback should return a boolean. **Note**: This behavior won't be triggered when the popover or any of its descendants are in focus.

hideOnInteractOutside

false | true | (arg: Event | SyntheticEvent<Element, Event>) => boolean | undefined = true

Determines if the dialog should hide when the user clicks or focuses on an element outside the dialog. This prop can be either a boolean or a function that takes an event as an argument and returns a boolean. The event object represents the event that triggered the action, which could be a native event or a React synthetic event of various types. Live examples: - [Selection Popover](https://ariakit.org/examples/popover-selection)

initialFocus

HTMLElement | RefObject<HTMLElement>

Specifies the element that will receive focus when the dialog is first opened. It can be an `HTMLElement` or a `React.RefObject` with an `HTMLElement`. If [`autoFocusOnShow`](https://ariakit.org/reference/dialog#autofocusonshow) is set to `false`, this prop will have no effect. If left unset, the dialog will attempt to determine the initial focus element in the following order: 1. A [Focusable](https://ariakit.org/components/focusable) element with an [`autoFocus`](https://ariakit.org/reference/focusable#autofocus) prop. 2. The first tabbable element inside the dialog. 3. The first focusable element inside the dialog. 4. The dialog element itself.

modal

Boolean | undefined = false

Determines whether the dialog is modal. Modal dialogs have distinct states and behaviors: - The [`portal`](https://ariakit.org/reference/dialog#portal) and [`preventBodyScroll`](https://ariakit.org/reference/dialog#preventbodyscroll) props are set to `true`. They can still be manually set to `false`. - When using the [`Heading`](https://ariakit.org/reference/heading) or [`DialogHeading`](https://ariakit.org/reference/dialog-heading) components within the dialog, their level will be reset so they start with `h1`. - A visually hidden dismiss button will be rendered if the [`DialogDismiss`](https://ariakit.org/reference/dialog-dismiss) component hasn't been used. This allows screen reader users to close the dialog. - When the dialog is open, element tree outside it will be inert. Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details) - [Form with Select](https://ariakit.org/examples/form-select) - [Context menu](https://ariakit.org/examples/menu-context-menu) - [Responsive Popover](https://ariakit.org/examples/popover-responsive)

onClose

() => void

call a function when popover closed

onFocusVisible

BivariantCallback<(event: SyntheticEvent<HTMLElement, Event>) => void>

Custom event handler invoked when the element gains focus through keyboard interaction or a key press occurs while the element is in focus. This is the programmatic equivalent of the [`data-focus-visible`](https://ariakit.org/guide/styling#data-focus-visible) attribute. **Note**: For this prop to work, the [`focusable`](https://ariakit.org/reference/command#focusable) prop must be set to `true`, if it's not set by default. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Custom Checkbox](https://ariakit.org/examples/checkbox-custom)

open

Boolean

Controls the open state of the dialog. This is similar to the [`open`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/open) attribute on native dialog elements. Live examples: - [Dialog with scrollable backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable) - [Dialog with details & summary](https://ariakit.org/examples/dialog-details) - [Warning on Dialog hide](https://ariakit.org/examples/dialog-hide-warning) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)

overflowPadding

number | undefined = 8

The minimum padding between the popover and the viewport edge. This will be exposed to CSS as [`--popover-overflow-padding`](https://ariakit.org/guide/styling#--popover-overflow-padding). Live examples: - [Sliding Menu](https://ariakit.org/examples/menu-slide)

overlap

Boolean | undefined = false

Whether the popover can overlap the anchor element when it overflows. Live examples: - [Menubar](https://ariakit.org/components/menubar) - [Submenu with Combobox](https://ariakit.org/examples/menu-nested-combobox)

portal

Boolean | undefined = true

Determines whether the element should be rendered as a React Portal. Live examples: - [Combobox with integrated filter](https://ariakit.org/examples/combobox-filtering-integrated) - [Dialog with Menu](https://ariakit.org/examples/dialog-menu) - [Hovercard with keyboard support](https://ariakit.org/examples/hovercard-disclosure) - [Menubar](https://ariakit.org/components/menubar) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Animated Select](https://ariakit.org/examples/select-animated)

portalElement

HTMLElement | (element: HTMLElement) => HTMLElement

An HTML element or a memoized callback function that returns an HTML element to be used as the portal element. By default, the portal element will be a `div` element appended to the `document.body`. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) @example ```jsx const [portal, setPortal] = useState(null); <Portal portalElement={portal} /> <div ref={setPortal} /> ``` @example ```jsx const getPortalElement = useCallback(() => { const div = document.createElement("div"); const portalRoot = document.getElementById("portal-root"); portalRoot.appendChild(div); return div; }, []); <Portal portalElement={getPortalElement} /> ```

portalRef

RefCallback<HTMLElement> | MutableRefObject<HTMLElement>

`portalRef` is similar to `ref` but is scoped to the portal node. It's useful when you need to be informed when the portal element is appended to the DOM or removed from the DOM. Live examples: - [Form with Select](https://ariakit.org/examples/form-select) @example ```jsx const [portalElement, setPortalElement] = useState(null); <Portal portalRef={setPortalElement} /> ```

preserveTabOrder

Boolean | undefined = false

When enabled, `preserveTabOrder` will keep the DOM element's tab order the same as the order in which the underlying [`Portal`](https://ariakit.org/reference/portal) component was mounted in the React tree. If the [`preserveTabOrderAnchor`](https://ariakit.org/reference/portal#preservetaborderanchor) prop is provided, the tab order will be preserved relative to that element.

preserveTabOrderAnchor

Element

An anchor element for maintaining the tab order when [`preserveTabOrder`](https://ariakit.org/reference/portal#preservetaborder) prop is enabled. The tab order will be kept relative to this element. By default, the tab order is kept relative to the original location in the React tree where the underlying [`Portal`](https://ariakit.org/reference/portal) component was mounted. @example ```jsx {18-20} const [anchor, setAnchor] = useState(null); <button ref={setAnchor}>Order 0</button> <button>Order 2</button> // Rendered at the end of the document. <Portal> <button>Order 5</button> </Portal> // Rendered at the end of the document, but the tab order is preserved. <Portal preserveTabOrder> <button>Order 3</button> </Portal> // Rendered at the end of the document, but the tab order is preserved // relative to the anchor element. <Portal preserveTabOrder preserveTabOrderAnchor={anchor}> <button>Order 1</button> </Portal> <button>Order 4</button> ```

preventBodyScroll

Boolean

Determines whether the body scrolling will be prevented when the dialog is shown. This is automatically set to `true` when the dialog is [`modal`](https://ariakit.org/reference/dialog#modal). You can disable this prop if you want to implement your own logic.

render

ReactElement<any, string | JSXElementConstructor<any>> | RenderProp<HTMLAttributes<any> & { ref?: Ref<any>; }>

Allows the component to be rendered as a different HTML element or React component. The value can be a React element or a function that takes in the original component props and gives back a React element with the props merged. Check out the [Composition](https://ariakit.org/guide/composition) guide for more details.

sameWidth

Boolean | undefined = false

Whether the popover should have the same width as the anchor element. This will be exposed to CSS as [`--popover-anchor-width`](https://ariakit.org/guide/styling#--popover-anchor-width).

shift

number | undefined = 0

The skidding of the popover along the anchor element. Can be set to negative values to make the popover shift to the opposite side. Live examples: - [Combobox with tabs](https://ariakit.org/examples/combobox-tabs) - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Submenu](https://ariakit.org/examples/menu-nested) - [Menubar](https://ariakit.org/components/menubar)

slide

Boolean | undefined = true

Whether the popover should slide when it overflows.

store
Required

HovercardStore & Pick<UsePopoverHoverProps, "withCloseButton">

Object returned by the [`useHovercardStore`](https://ariakit.org/reference/use-hovercard-store) hook. If not provided, the closest [`HovercardProvider`](https://ariakit.org/reference/hovercard-provider) component's context will be used.

unmountOnHide

Boolean | undefined = false

When set to `true`, the content element will be unmounted and removed from the DOM when it's hidden. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Combobox with integrated filter](https://ariakit.org/examples/combobox-filtering-integrated) - [Textarea with inline Combobox](https://ariakit.org/examples/combobox-textarea) - [Standalone Popover](https://ariakit.org/examples/popover-standalone) - [Animated Select](https://ariakit.org/examples/select-animated) - [Multi-Select](https://ariakit.org/examples/select-multiple)

updatePosition

(props: { updatePosition: () => Promise<void>; }) => void | Promise<void>

A callback that will be called when the popover needs to calculate its position. This will override the internal `updatePosition` function. The original `updatePosition` function will be passed as an argument, so it can be called inside the callback to apply the default behavior. Live examples: - [Responsive Popover](https://ariakit.org/examples/popover-responsive)

wrapElement

WrapElement

wrapperProps

HTMLAttributes<HTMLDivElement>

Props that will be passed to the popover wrapper element. This element will be used to position the popover. Live examples: - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation) - [Sliding Menu](https://ariakit.org/examples/menu-slide)

PopoverHoverTrigger

PopoverTrigger

usePopover

animated

number | false | true | undefined = 150

Determines whether the content should animate when it is shown or hidden. - If `true`, the `animating` state will be `true` when the content is shown or hidden and it will wait for a CSS animation/transition to end before becoming `false`. - If it's set to a number, the `animating` state will be `true` when the content is shown or hidden and it will wait for the number of milliseconds to pass before becoming `false`. @deprecated Manually setting the `animated` prop is no longer necessary. This will be removed in a future release.

defaultOpen

Boolean | undefined = false

Whether the content should be visible by default.

disclosure

DisclosureStore

A reference to another disclosure store that controls another disclosure component to keep them in sync. Element states like `contentElement` and `disclosureElement` won't be synced. For that, use the [`store`](https://ariakit.org/reference/disclosure-provider#store) prop instead. Live examples: - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)

popover

PopoverStore

A reference to another popover store that's controlling another popover to keep them in sync.

setMounted

(mounted: boolean) => void

A callback that gets called when the `mounted` state changes. @example const [mounted, setMounted] = useState(false); const disclosure = useDisclosureStore({ setMounted });

setOpen

(open: boolean) => void

A callback that gets called when the [`open`](https://ariakit.org/reference/disclosure-provider#open) state changes. @example const [open, setOpen] = useState(false); const disclosure = useDisclosureStore({ open, setOpen });

usePopoverHover

animated

number | false | true | undefined = 150

Determines whether the content should animate when it is shown or hidden. - If `true`, the `animating` state will be `true` when the content is shown or hidden and it will wait for a CSS animation/transition to end before becoming `false`. - If it's set to a number, the `animating` state will be `true` when the content is shown or hidden and it will wait for the number of milliseconds to pass before becoming `false`. @deprecated Manually setting the `animated` prop is no longer necessary. This will be removed in a future release.

defaultOpen

Boolean | undefined = false

Whether the content should be visible by default.

disclosure

DisclosureStore

A reference to another disclosure store that controls another disclosure component to keep them in sync. Element states like `contentElement` and `disclosureElement` won't be synced. For that, use the [`store`](https://ariakit.org/reference/disclosure-provider#store) prop instead. Live examples: - [Command Menu](https://ariakit.org/examples/dialog-combobox-command-menu)

popover

PopoverStore

A reference to another popover store that's controlling another popover to keep them in sync.

setMounted

(mounted: boolean) => void

A callback that gets called when the `mounted` state changes. @example const [mounted, setMounted] = useState(false); const disclosure = useDisclosureStore({ setMounted });

setOpen

(open: boolean) => void

A callback that gets called when the [`open`](https://ariakit.org/reference/disclosure-provider#open) state changes. @example const [open, setOpen] = useState(false); const disclosure = useDisclosureStore({ open, setOpen });