---
title: Popover
description: "`Popover` is a component that floats around an element to display information."
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/popover/popover.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/popover
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-popover--basic
---
# Popover
`Popover` is a component that floats around an element to display information.
```tsx
空条承太郎やれやれだぜ
```
## Usage
```tsx
import { Popover } from "@yamada-ui/react"
```
```tsx
import { Popover } from "@/components/ui"
```
```tsx
import { Popover } from "@workspaces/ui"
```
```tsx
```
### Change Size
```tsx
{(size) => (
花京院典明レロレロレロレロレロレロ
)}
```
### Add Footer
```tsx
ジョルノ・ジョバァーナ僕には夢がある黄金の風
```
### Display Popover on Different Element
To display a popover on a different element, use `Popover.Anchor`.
```tsx
Here Display Popover
ジョセフ・ジョースターお前の次のセリフは…「そんなバカな!」と言う
```
### Change Animation
To change the animation, set `animationScheme` to `"block-start"`, `"inline-end"`, etc. By default, `"scale"` is set.
```tsx
{(animationScheme) => (
ブローノ・ブチャラティアリーヴェデルチ(さよならだ)
)}
```
### Change Placement
To change the placement, set `placement` to `"start"`, `"end-end"`, etc. By default, `"end"` is set.
```tsx
{(placement) => (
ディアボロこれが…レクイエム…だ
)}
```
### Change Duration
To change the duration, set `duration` to a number (seconds).
```tsx
吉良吉影僕は平穏に暮らしたいだけなんだ
```
### Change Offset
To change the offset, set `gutter` or `offset` to a value.
```tsx
東方仗助グレートだぜ東方仗助グレートだぜ
```
### Use Modal
To use modal, set `modal` to `true`. This enables scroll blocking and focus trapping.
```tsx
フーゴ・パンナコッタ
```
### Disable
To disable the popover, set `disabled` to `true`.
```tsx
虹村億泰おい、仗助!
```
### Disable Close on Outside Click
To disable closing when clicking outside, set `closeOnBlur` to `false`.
```tsx
イギーんがくく(犬の鳴き声)
```
### Disable Close on ESC Key
To disable closing when pressing the ESC key, set `closeOnEsc` to `false`.
```tsx
ディオ・ブランドー無駄無駄無駄!
```
### Disable Auto Focus
To disable automatic focus when the popover opens, set `autoFocus` to `false`.
```tsx
岸辺露伴
```
### Set Initial Focus
To set the initial focus, pass a `Ref` to `initialFocusRef`.
```tsx
const inputRef = useRef(null)
return (
ナランチャ・ギルガ
)
```
### Block Scroll
To block scrolling while the popover is open, set `blockScrollOnMount` to `true`.
```tsx
岸辺露伴だが断る
```
### Close on Scroll
To automatically close the popover when scrolling, set `closeOnScroll` to `true`.
```tsx
ギアッチョ根掘り葉掘り聞きやがって!
```
### Nest Popovers
```tsx
花京院典明やはりエジプトか……いつ出発する?空条承太郎花京院
```
### Control
```tsx
const { open, onClose, onOpen } = useDisclosure()
return (
スピードワゴン
こいつはくせえッー! ゲロ以下のにおいがプンプンするぜッーーーーッ!!
)
```
## Props
### Popover.Root
| Prop | Default | Type | Description |
| -------------------- | --------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `size` | `"md"` | `"lg" \| "md" \| "sm" \| "xs"` | The size of the component. |
| `anchor` | - | `ReactNode` | The popover anchor to use. |
| `anchorProps` | - | `Omit` | Props for anchor element. |
| `animationScheme` | `"scale"` | `"block-end" \| "block-start" \| "inline-end" \| "inline-start" \| "none" \| "scale" ...` | The animation of the element. |
| `autoFocus` | `true` | `boolean` | If `true`, focus will be transferred to the first interactive element when the popover opens. |
| `autoUpdate` | `true` | `boolean` | If `true`, automatically updates the position of the floating element when necessary. |
| `blockScrollOnMount` | `false` | `boolean` | If `true`, scrolling will be disabled on the `body` when the modal opens. |
| `body` | - | `PopoverBodyProps \| ReactNode` | The popover body to use. |
| `bodyProps` | - | `Omit` | Props for body element. |
| `children` | - | `ReactNodeOrFunction<{ |
open: boolean
onClose: () => void
}>`| The children of the popover. |
|`closeOnBlur`|`true`|`boolean`| If`true`, the popover will close when you blur out it by clicking outside or tabbing out. |
| `closeOnEsc`|`true`|`boolean`| If`true`, the popover will hide on pressing Esc key. |
| `closeOnScroll`|`false`|`boolean`| If`true`, the popover will hide on scroll. |
| `closeTriggerProps`| - |`Omit`| Props for close trigger element. |
|`contentProps`| - |`Omit`| Props for content element. |
|`defaultOpen`| - |`boolean`| If`true`, the element will be initially opened. |
| `disabled`|`false`|`boolean`| If`true`, the popover will be disabled. |
| `duration`|`0.1`|`MotionLifecycleProps \| number`| The animation duration. |
|`elements`| - |`{ floating?: HTMLElement \| null \| undefined; reference?: HTMLButtonElement \| null \| undefined; }`| Object containing the reference and floating elements. |
|`flip`|`true`|`boolean`| If`true`, the popper will change its placement and flip when it's about to overflow its boundary area. |
| `footer`| - |`PopoverFooterProps \| ReactNode`| The popover footer to use. |
|`footerProps`| - |`Omit`| Props for footer element. |
|`gutter`|`8`|`number`| The distance or margin between the reference and popper. It is used internally to create an`offset`modifier. |
|`header`| - |`PopoverHeaderProps \| ReactNode`| The popover header to use. |
|`headerProps`| - |`Omit`| Props for header element. |
|`initialFocusRef`| - |`RefObject`| The`ref`of the element that should receive focus when the popover opens. |
|`matchWidth`|`false`|`boolean`| If`true`, the popper will match the width of the reference at all times. It's useful for `autocomplete`, `date-picker`and`select`patterns. |
|`middleware`| - |`(false \| { name: string; options?: any; fn: (state: { x: number; y: number; placement: Placement; platform: { detectOverflow: (state: MiddlewareState, options?: DetectOverflowOptions \| Derivable<...> \| undefined) => Promise<...>; } & Platform; ... 4 more ...; elements: Elements; }) => Promisable<...>; } \| null \| und...`| Array of middleware objects to modify the positioning or provide data for rendering. |
|`modal`|`false`|`boolean`| If`true`, the popover will be modal. - scrolling is blocked. - focus is trapped within the popover. |
| `offset`| - |`[number, number]`| The main and cross-axis offset to displace popper element from its reference element. |
|`onClose`| - |`() => void \| Promise`| Callback invoked to close the element. |
|`onOpen`| - |`() => void \| Promise`| Callback invoked to open the element. |
|`open`| - |`boolean`| If`true`, the element will be opened. |
| `openOnClick`|`true`|`boolean`| If`true`, the popover will be opened when click on the field. |
| `placement`|`"end"`|`"center-end-end" \| "center-end-start" \| "center-end" \| "center-start-end" \| "center-start-start" \| "center-start" \| "end-center" \| "end-end" \| "end-start" \| "end" ...`| The placement of the popper relative to its reference. |
|`platform`| - |`Platform`| Custom or extended platform object. |
|`preventOverflow`|`true`|`boolean`| If`true`, will prevent the popper from being cut off and ensure it's visible within the boundary area. |
| `strategy`|`"absolute"`|`"absolute" \| "fixed"`| The CSS positioning strategy to use. |
|`transferFocus`|`true`|`boolean`| If`true`, the focus will be transferred to the popover content when the tab key is pressed. |
| `transform`|`true`|`boolean`| Whether to use`transform`for positioning instead of`top`and`left`(layout) in the`floatingStyles`object. |
|`trigger`| - |`ReactNode`| The popover trigger to use. |
|`triggerProps`| - |`Omit`| Props for trigger element. |
|`updateRef`| - |`RefObject<() => void>`| Update the position of the floating element, re-rendering the component if required. |
|`whileElementsMounted`| - |`(reference: HTMLButtonElement, floating: HTMLElement, update: () => void) => () => void`| A callback invoked when both the reference and floating elements are mounted, and cleaned up when either is unmounted. This is useful for setting up event listeners (e.g. pass`autoUpdate`). |
### Popover.Anchor
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Popover.Body
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Popover.CloseTrigger
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Popover.Content
| Prop | Default | Type | Description |
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `keyof IntrinsicElements` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `portalProps` | - | `Omit` | Props for portal component. |
| `positionerProps` | - | `Omit` | Props for positioner component. |
### Popover.Footer
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Popover.Header
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
### Popover.Trigger
| Prop | Default | Type | Description |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `as` | - | `As` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
## Accessibility
The `Popover` follows the [WAI-ARIA - Dialog (Modal) Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/) for accessibility.
### Keyboard Navigation
| Key | Description | State |
| --------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `Tab` | Focuses the next element within the popover that is not disabled. If it's the last element, the popover is closed. | `open={true}` |
| `Shift` + `Tab` | Focuses the previous element within the popover that is not disabled. If it's the first element, the popover is closed. | `open={true}` |
| `Escape` | Closes the popover. | `open={true}` + `closeOnEsc={true}` |
### ARIA Roles and Attributes
| Element | Roles and Attributes | Usage |
| :--------------------------- | :----------------------- | :----------------------------------------------------------------------------------------------- |
| `div.ui-popover__content` | `role="dialog"` | Indicates that it is a dialog. |
| | `id` | Used to associate with `button.ui-popover__trigger`. |
| | `aria-labelledby` | Sets the `id` of the associated `div.ui-popover__header`. |
| | `aria-describedby` | Sets the `id` of the associated `div.ui-popover__body`. |
| | `aria-hidden` | Sets to `"false"` when popover is opened, and `"true"` when it is closed. |
| | `aria-modal` | Sets to `"true"` when `modal={true}`. |
| `button.ui-popover__trigger` | `role="button"` | Indicates that it is a button. |
| | `aria-disabled` | Sets to `"true"` when `disabled={true}`. |
| | `aria-expanded` | Sets to `"true"` when popover is opened, and `"false"` when it is closed. |
| | `aria-controls` | Set to `div.ui-popover__content`'s id when popover is opened, and `undefined` when it is closed. |
| | `aria-haspopup="dialog"` | Indicates that it triggers a dialog. |
| `div.ui-popover__header` | `id` | Used to associate with `div.ui-popover__content`. |
| `div.ui-popover__body` | `id` | Used to associate with `div.ui-popover__content`. |
## Similar Components
- [Tooltip](https://yamada-ui.com/docs/components/tooltip.md): `Tooltip` is a component that displays short information, such as supplementary details for an element.
- [Drawer](https://yamada-ui.com/docs/components/drawer.md): `Drawer` is a component for a panel that appears from the edge of the screen.
- [Modal](https://yamada-ui.com/docs/components/modal.md): `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.
- [NativePopover](https://yamada-ui.com/docs/components/native-popover.md): `NativePopover` is a component that floats around an element to display information using the HTML Popover API.
- [ActionBar](https://yamada-ui.com/docs/components/action-bar.md): `ActionBar` is a component that is used to display a bottom action bar with a set of actions.
- [Menu](https://yamada-ui.com/docs/components/menu.md): `Menu` is a component that displays a common dropdown menu.
## Uses Components & Hooks
- [NativePopover](https://yamada-ui.com/docs/components/native-popover.md): `NativePopover` is a component that floats around an element to display information using the HTML Popover API.
- [Button](https://yamada-ui.com/docs/components/button.md): `Button` is an interactive component that allows users to perform actions such as submitting forms and toggling modals.
- [Motion](https://yamada-ui.com/docs/components/motion.md): `Motion` is a convenient component that extends the Yamada UI Style Props to `Motion`.
- [Portal](https://yamada-ui.com/docs/components/portal.md): `Portal` is a component that renders elements outside of the current `DOM` hierarchy.
- [FadeScale](https://yamada-ui.com/docs/components/fade-scale.md): `FadeScale` is a component that gradually scales up to reveal or scales down to hide an element.
- [SlideFade](https://yamada-ui.com/docs/components/slide-fade.md): `SlideFade` is a component that gradually shows or hides an element while moving it from a specified position.
- [useValue](https://yamada-ui.com/docs/hooks/use-value.md): `useValue` is a custom hook that combines `useBreakpointValue` and `useColorModeValue`.
- [useDisclosure](https://yamada-ui.com/docs/hooks/use-disclosure.md): `useDisclosure` is a custom hook that helps handle common open/close or toggle scenarios. It can be used to control components such as `Modal`, `Dialog`, `Drawer`, etc.
- [useOutsideClick](https://yamada-ui.com/docs/hooks/use-outside-click.md): `useOutsideClick` is a custom hook that detects click events outside of an element.
## Used By Components & Hooks
- [ActionBar](https://yamada-ui.com/docs/components/action-bar.md): `ActionBar` is a component that is used to display a bottom action bar with a set of actions.
- [Autocomplete](https://yamada-ui.com/docs/components/autocomplete.md): `Autocomplete` is a component used to display suggestions in response to user text input.
- [ColorPicker](https://yamada-ui.com/docs/components/color-picker.md): `ColorPicker` is a component used by the user to select a color or enter an arbitrary color value.
- [DatePicker](https://yamada-ui.com/docs/components/date-picker.md): `DatePicker` is a component used for users to select a date.
- [Menu](https://yamada-ui.com/docs/components/menu.md): `Menu` is a component that displays a common dropdown menu.
- [Modal](https://yamada-ui.com/docs/components/modal.md): `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.
- [Select](https://yamada-ui.com/docs/components/select.md): `Select` is a component used for allowing a user to choose values from a list of options.
- [Tooltip](https://yamada-ui.com/docs/components/tooltip.md): `Tooltip` is a component that displays short information, such as supplementary details for an element.