# Popover URL: https://ark-ui.com/docs/components/popover Source: https://raw.githubusercontent.com/chakra-ui/ark/refs/heads/main/website/src/content/pages/components/popover.mdx An overlay that displays additional information or options when triggered. --- ## Anatomy ```tsx ``` ## Examples **Example: basic** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Basic = () => ( Click Me Favorite Frameworks Manage and organize your favorite web frameworks. ) ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Basic = () => ( Click Me Favorite Frameworks Manage and organize your favorite web frameworks. ) ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Favorite Frameworks Manage and organize your favorite web frameworks. ``` ### Controlled Use the `open` and `onOpenChange` props to control the open state of the popover. **Example: controlled** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import { useState } from 'react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Controlled = () => { const [open, setOpen] = useState(false) return ( setOpen(e.open)}> Click Me Team Members Invite colleagues to collaborate on this project. ) } ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { createSignal } from 'solid-js' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Controlled = () => { const [open, setOpen] = createSignal(false) return ( setOpen(e.open)}> Click Me Team Members Invite colleagues to collaborate on this project. ) } ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Team Members Invite colleagues to collaborate on this project. ``` ### Root Provider An alternative way to control the popover is to use the `RootProvider` component and the `usePopover` hook. This way you can access the state and methods from outside the component. **Example: root-provider** #### React ```tsx import { Popover, usePopover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const RootProvider = () => { const popover = usePopover({ positioning: { placement: 'bottom-start', }, }) return (
Controlled Externally This popover is controlled via the usePopover hook.
) } ``` #### Solid ```tsx import { Popover, usePopover } from '@ark-ui/solid/popover' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const RootProvider = () => { const popover = usePopover() return (
Controlled Externally This popover is controlled via the usePopover hook.
) } ``` #### Vue ```vue ``` #### Svelte ```svelte
Controlled Externally This popover is controlled via the usePopover hook.
``` ### Arrow Use `Popover.Arrow` and `Popover.ArrowTip` to render an arrow pointing to the trigger. **Example: arrow** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Arrow = () => ( Click Me Notifications You have 3 unread messages in your inbox. ) ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Arrow = () => ( Click Me Notifications You have 3 unread messages in your inbox. ) ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Notifications You have 3 unread messages in your inbox. ``` ### Placement To change the placement of the popover, set the `positioning` prop. **Example: positioning** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Positioning = () => ( Click Me Left Placement This popover appears on the left with custom offset values. ) ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Positioning = () => ( Click Me Left Placement This popover appears on the left with custom offset values. ) ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Left Placement This popover appears on the left with custom offset values. ``` ### Close Behavior The popover is designed to close on blur and when the esc key is pressed. - To prevent it from closing on blur (clicking or focusing outside), pass the `closeOnInteractOutside` prop and set it to `false`. - To prevent it from closing when the esc key is pressed, pass the `closeOnEsc` prop and set it to `false`. **Example: close-behavior** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const CloseBehavior = () => ( Click Me Quick Actions Press Escape or click outside to close this popover. ) ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const CloseBehavior = () => ( Click Me Quick Actions Press Escape or click outside to close this popover. ) ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Quick Actions Press Escape or click outside to close this popover. ``` ### Modality In some cases, you might want the popover to be modal. This means that it'll: - trap focus within its content - block scrolling on the body - disable pointer interactions outside the popover - hide content behind the popover from screen readers To make the popover modal, set the `modal` prop to `true`. When `modal={true}`, we set the `portalled` attribute to `true` as well. **Example: modal** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Modal = () => ( Click Me Confirm Action Focus is trapped inside this modal popover until dismissed. ) ``` #### Solid ```tsx import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Modal = () => ( Click Me Confirm Action Focus is trapped inside this modal popover until dismissed. ) ``` #### Vue ```vue ``` #### Svelte ```svelte Click Me Confirm Action Focus is trapped inside this modal popover until dismissed. ``` ### Anchor Use `Popover.Anchor` to position the popover relative to a different element than the trigger. **Example: anchor** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import field from 'styles/field.module.css' import styles from 'styles/popover.module.css' export const Anchor = () => { return (
Click Me
Title Description
) } ``` ### Same Width Use `positioning.sameWidth` to make the popover match the width of its trigger element. **Example: same-width** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const SameWidth = () => { return ( Click Me Matched Width This popover matches the width of its trigger element. ) } ``` ### Dialog Integration When rendering a popover inside a dialog, you have two options for proper layering: 1. **Keep the Portal with `lazyMount` and `unmountOnExit`** - This ensures the popover is properly unmounted when the dialog closes, preventing stale DOM nodes. 2. **Remove the Portal** - Render the popover inline within the dialog content. This works well but may have z-index considerations. **Example: with-dialog** #### React ```tsx import { Dialog } from '@ark-ui/react/dialog' import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import { XIcon } from 'lucide-react' import button from 'styles/button.module.css' import dialog from 'styles/dialog.module.css' import styles from 'styles/popover.module.css' export const WithDialog = () => ( Open Dialog Edit Profile Update your profile information below.
More Options Additional Settings This popover renders correctly above the dialog.
) ``` #### Solid ```tsx import { Dialog } from '@ark-ui/solid/dialog' import { Popover } from '@ark-ui/solid/popover' import { XIcon } from 'lucide-solid' import { Portal } from 'solid-js/web' import button from 'styles/button.module.css' import dialog from 'styles/dialog.module.css' import styles from 'styles/popover.module.css' export const WithDialog = () => ( Open Dialog Edit Profile Update your profile information below.
More Options Additional Settings This popover renders correctly above the dialog.
) ``` #### Vue ```vue ``` #### Svelte ```svelte Open Dialog Edit Profile Update your profile information below.
More Options Additional Settings This popover renders correctly above the dialog.
``` ### Nested Popovers can be nested within each other. Each nested popover maintains its own open state and positioning. **Example: nested** #### React ```tsx import { Popover } from '@ark-ui/react/popover' import { Portal } from '@ark-ui/react/portal' import button from 'styles/button.module.css' import styles from 'styles/popover.module.css' export const Nested = () => { return ( Click Me Settings Manage your preferences and account settings. Advanced Advanced Settings Configure advanced options for power users. ) } ``` ## Guides ### Available Size The following css variables are exposed to the `Popover.Positioner` which you can use to style the `Popover.Content` ```css /* width of the popover trigger */ --reference-width: ; /* width of the available viewport */ --available-width: ; /* height of the available viewport */ --available-height: ; ``` For example, if you want to make sure the maximum height doesn't exceed the available height, use the following css: ```css [data-scope='popover'][data-part='content'] { max-height: calc(var(--available-height) - 100px); } ``` ## API Reference ### Props **Component API Reference** #### React **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `autoFocus` | `boolean` | No | Whether to automatically set focus on the first focusable content within the popover when opened. | | `closeOnEscape` | `boolean` | No | Whether to close the popover when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | Whether to close the popover when the user clicks outside of the popover. | | `defaultOpen` | `boolean` | No | The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ anchor: string trigger: string content: string title: string description: string closeTrigger: string positioner: string arrow: string }>` | No | The ids of the elements in the popover. Useful for composition. | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `initialFocusEl` | `() => HTMLElement | null` | No | The element to focus on when the popover is opened. | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `modal` | `boolean` | No | Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover | | `onEscapeKeyDown` | `(event: KeyboardEvent) => void` | No | Function called when the escape key is pressed | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `onFocusOutside` | `(event: FocusOutsideEvent) => void` | No | Function called when the focus is moved outside the component | | `onInteractOutside` | `(event: InteractOutsideEvent) => void` | No | Function called when an interaction happens outside the component | | `onOpenChange` | `(details: OpenChangeDetails) => void` | No | Function invoked when the popover opens or closes | | `onPointerDownOutside` | `(event: PointerDownOutsideEvent) => void` | No | Function called when the pointer is pressed down outside the component | | `onRequestDismiss` | `(event: LayerDismissEvent) => void` | No | Function called when this layer is closed due to a parent layer being closed | | `open` | `boolean` | No | The controlled open state of the popover | | `persistentElements` | `(() => Element | null)[]` | No | Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | | `portalled` | `boolean` | No | Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. | | `positioning` | `PositioningOptions` | No | The user provided options used to position the popover content | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Anchor Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow CSS Variables:** | Variable | Description | |----------|-------------| | `--arrow-size` | The size of the arrow | | `--arrow-size-half` | Half the size of the arrow | | `--arrow-background` | Use this variable to style the arrow background | | `--arrow-offset` | The offset position of the arrow | **ArrowTip Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **CloseTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | content | | `[data-state]` | "open" | "closed" | | `[data-nested]` | popover | | `[data-has-nested]` | popover | | `[data-expanded]` | Present when expanded | | `[data-placement]` | The placement of the content | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--layer-index` | The index of the dismissable in the layer stack | | `--nested-layer-count` | The number of nested popovers | **Description Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | indicator | | `[data-state]` | "open" | "closed" | **Positioner Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Positioner CSS Variables:** | Variable | Description | |----------|-------------| | `--reference-width` | The width of the reference element | | `--reference-height` | The height of the root | | `--available-width` | The available width in viewport | | `--available-height` | The available height in viewport | | `--x` | The x position for transform | | `--y` | The y position for transform | | `--z-index` | The z-index value | | `--transform-origin` | The transform origin for animations | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UsePopoverReturn` | Yes | | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Title Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | trigger | | `[data-placement]` | The placement of the trigger | | `[data-state]` | "open" | "closed" | #### Solid **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `autoFocus` | `boolean` | No | Whether to automatically set focus on the first focusable content within the popover when opened. | | `closeOnEscape` | `boolean` | No | Whether to close the popover when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | Whether to close the popover when the user clicks outside of the popover. | | `defaultOpen` | `boolean` | No | The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ anchor: string trigger: string content: string title: string description: string closeTrigger: string positioner: string arrow: string }>` | No | The ids of the elements in the popover. Useful for composition. | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `initialFocusEl` | `() => HTMLElement | null` | No | The element to focus on when the popover is opened. | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `modal` | `boolean` | No | Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover | | `onEscapeKeyDown` | `(event: KeyboardEvent) => void` | No | Function called when the escape key is pressed | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `onFocusOutside` | `(event: FocusOutsideEvent) => void` | No | Function called when the focus is moved outside the component | | `onInteractOutside` | `(event: InteractOutsideEvent) => void` | No | Function called when an interaction happens outside the component | | `onOpenChange` | `(details: OpenChangeDetails) => void` | No | Function invoked when the popover opens or closes | | `onPointerDownOutside` | `(event: PointerDownOutsideEvent) => void` | No | Function called when the pointer is pressed down outside the component | | `onRequestDismiss` | `(event: LayerDismissEvent) => void` | No | Function called when this layer is closed due to a parent layer being closed | | `open` | `boolean` | No | The controlled open state of the popover | | `persistentElements` | `(() => Element | null)[]` | No | Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | | `portalled` | `boolean` | No | Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. | | `positioning` | `PositioningOptions` | No | The user provided options used to position the popover content | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Anchor Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow CSS Variables:** | Variable | Description | |----------|-------------| | `--arrow-size` | The size of the arrow | | `--arrow-size-half` | Half the size of the arrow | | `--arrow-background` | Use this variable to style the arrow background | | `--arrow-offset` | The offset position of the arrow | **ArrowTip Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **CloseTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'button'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | content | | `[data-state]` | "open" | "closed" | | `[data-nested]` | popover | | `[data-has-nested]` | popover | | `[data-expanded]` | Present when expanded | | `[data-placement]` | The placement of the content | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--layer-index` | The index of the dismissable in the layer stack | | `--nested-layer-count` | The number of nested popovers | **Description Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | indicator | | `[data-state]` | "open" | "closed" | **Positioner Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Positioner CSS Variables:** | Variable | Description | |----------|-------------| | `--reference-width` | The width of the reference element | | `--reference-height` | The height of the root | | `--available-width` | The available width in viewport | | `--available-height` | The available height in viewport | | `--x` | The x position for transform | | `--y` | The y position for transform | | `--z-index` | The z-index value | | `--transform-origin` | The transform origin for animations | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UsePopoverReturn` | Yes | | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Title Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'div'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `(props: ParentProps<'button'>) => Element` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | trigger | | `[data-placement]` | The placement of the trigger | | `[data-state]` | "open" | "closed" | #### Vue **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `autoFocus` | `boolean` | No | Whether to automatically set focus on the first focusable content within the popover when opened. | | `closeOnEscape` | `boolean` | No | Whether to close the popover when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | Whether to close the popover when the user clicks outside of the popover. | | `defaultOpen` | `boolean` | No | The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ anchor: string trigger: string content: string title: string description: string closeTrigger: string positioner: string arrow: string }>` | No | The ids of the elements in the popover. Useful for composition. | | `initialFocusEl` | `() => HTMLElement | null` | No | The element to focus on when the popover is opened. | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `modal` | `boolean` | No | Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover | | `open` | `boolean` | No | The controlled open state of the popover | | `persistentElements` | `(() => Element | null)[]` | No | Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | | `portalled` | `boolean` | No | Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. | | `positioning` | `PositioningOptions` | No | The user provided options used to position the popover content | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Anchor Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Arrow CSS Variables:** | Variable | Description | |----------|-------------| | `--arrow-size` | The size of the arrow | | `--arrow-size-half` | Half the size of the arrow | | `--arrow-background` | Use this variable to style the arrow background | | `--arrow-offset` | The offset position of the arrow | **ArrowTip Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **CloseTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | content | | `[data-state]` | "open" | "closed" | | `[data-nested]` | popover | | `[data-has-nested]` | popover | | `[data-expanded]` | Present when expanded | | `[data-placement]` | The placement of the content | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--layer-index` | The index of the dismissable in the layer stack | | `--nested-layer-count` | The number of nested popovers | **Description Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Indicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | indicator | | `[data-state]` | "open" | "closed" | **Positioner Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Positioner CSS Variables:** | Variable | Description | |----------|-------------| | `--reference-width` | The width of the reference element | | `--reference-height` | The height of the root | | `--available-width` | The available width in viewport | | `--available-height` | The available height in viewport | | `--x` | The x position for transform | | `--y` | The y position for transform | | `--z-index` | The z-index value | | `--transform-origin` | The transform origin for animations | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `PopoverApi` | Yes | | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Title Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `boolean` | No | Use the provided child element as the default rendered element, combining their props and behavior. | **Trigger Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | trigger | | `[data-placement]` | The placement of the trigger | | `[data-state]` | "open" | "closed" | #### Svelte **Root Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `autoFocus` | `boolean` | No | Whether to automatically set focus on the first focusable content within the popover when opened. | | `closeOnEscape` | `boolean` | No | Whether to close the popover when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | Whether to close the popover when the user clicks outside of the popover. | | `defaultOpen` | `boolean` | No | The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. | | `id` | `string` | No | The unique identifier of the machine. | | `ids` | `Partial<{ anchor: string trigger: string content: string title: string description: string closeTrigger: string positioner: string arrow: string }>` | No | The ids of the elements in the popover. Useful for composition. | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `initialFocusEl` | `() => HTMLElement | null` | No | The element to focus on when the popover is opened. | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `modal` | `boolean` | No | Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover | | `onEscapeKeyDown` | `(event: KeyboardEvent) => void` | No | Function called when the escape key is pressed | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `onFocusOutside` | `(event: FocusOutsideEvent) => void` | No | Function called when the focus is moved outside the component | | `onInteractOutside` | `(event: InteractOutsideEvent) => void` | No | Function called when an interaction happens outside the component | | `onOpenChange` | `(details: OpenChangeDetails) => void` | No | Function invoked when the popover opens or closes | | `onPointerDownOutside` | `(event: PointerDownOutsideEvent) => void` | No | Function called when the pointer is pressed down outside the component | | `onRequestDismiss` | `(event: LayerDismissEvent) => void` | No | Function called when this layer is closed due to a parent layer being closed | | `open` | `boolean` | No | The controlled open state of the popover | | `persistentElements` | `(() => Element | null)[]` | No | Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event | | `portalled` | `boolean` | No | Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. | | `positioning` | `PositioningOptions` | No | The user provided options used to position the popover content | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Anchor Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Arrow Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Arrow CSS Variables:** | Variable | Description | |----------|-------------| | `--arrow-size` | The size of the arrow | | `--arrow-size-half` | Half the size of the arrow | | `--arrow-background` | Use this variable to style the arrow background | | `--arrow-offset` | The offset position of the arrow | **ArrowTip Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **CloseTrigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'button'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Content Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Content Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | content | | `[data-state]` | "open" | "closed" | | `[data-nested]` | popover | | `[data-has-nested]` | popover | | `[data-expanded]` | Present when expanded | | `[data-placement]` | The placement of the content | **Content CSS Variables:** | Variable | Description | |----------|-------------| | `--layer-index` | The index of the dismissable in the layer stack | | `--nested-layer-count` | The number of nested popovers | **Context Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `render` | `Snippet<[UsePopoverContext]>` | No | | **Description Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'p'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Indicator Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Indicator Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | indicator | | `[data-state]` | "open" | "closed" | **Positioner Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'div'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Positioner CSS Variables:** | Variable | Description | |----------|-------------| | `--reference-width` | The width of the reference element | | `--reference-height` | The height of the root | | `--available-width` | The available width in viewport | | `--available-height` | The available height in viewport | | `--x` | The x position for transform | | `--y` | The y position for transform | | `--z-index` | The z-index value | | `--transform-origin` | The transform origin for animations | **RootProvider Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `value` | `UsePopoverReturn` | Yes | | | `immediate` | `boolean` | No | Whether to synchronize the present change immediately or defer it to the next frame | | `lazyMount` | `boolean` | No | Whether to enable lazy mounting | | `onExitComplete` | `VoidFunction` | No | Function called when the animation ends in the closed state | | `present` | `boolean` | No | Whether the node is present (controlled by the user) | | `skipAnimationOnMount` | `boolean` | No | Whether to allow the initial presence animation. | | `unmountOnExit` | `boolean` | No | Whether to unmount on exit. | **Title Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'h2'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Trigger Props:** | Prop | Type | Required | Description | |------|------|----------|-------------| | `asChild` | `Snippet<[PropsFn<'button'>]>` | No | Use the provided child element as the default rendered element, combining their props and behavior. | | `ref` | `Element` | No | | **Trigger Data Attributes:** | Attribute | Value | |-----------|-------| | `[data-scope]` | popover | | `[data-part]` | trigger | | `[data-placement]` | The placement of the trigger | | `[data-state]` | "open" | "closed" | ### Context **API:** | Property | Type | Description | |----------|------|-------------| | `portalled` | `boolean` | Whether the popover is portalled. | | `open` | `boolean` | Whether the popover is open | | `setOpen` | `(open: boolean) => void` | Function to open or close the popover | | `reposition` | `(options?: Partial) => void` | Function to reposition the popover | ## Accessibility ### Keyboard Support