---
title: Popover
description: "`Popover`は、要素の周りにフローティングして情報を表示するコンポーネントです。"
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
---
```tsx
空条承太郎
やれやれだぜ
```
## 使い方
```tsx
import { Popover } from "@yamada-ui/react"
```
```tsx
import { Popover } from "@/components/ui"
```
```tsx
import { Popover } from "@workspaces/ui"
```
```tsx
```
### サイズを変更する
```tsx
{(size) => (
花京院典明
レロレロレロレロレロレロ
)}
```
### フッターを追加する
```tsx
ジョルノ・ジョバァーナ
僕には夢がある
黄金の風
```
### 別の要素を参照して表示する
別の要素を参照して表示する場合は、`Popover.Anchor`を使用します。
```tsx
Here Display Popover
ジョセフ・ジョースター
お前の次のセリフは…「そんなバカな!」と言う
```
### アニメーションを変更する
アニメーションを変更する場合は、`animationScheme`に`"block-start"`や`"inline-end"`などを設定します。
デフォルトでは`"scale"`が設定されています。
```tsx
{(animationScheme) => (
ブローノ・ブチャラティ
アリーヴェデルチ(さよならだ)
)}
```
### 配置を変更する
配置を変更する場合は、`placement`に`"start"`や`"end-end"`などを指定します。デフォルトでは`"end"`が設定されています。
```tsx
{(placement) => (
ディアボロ
これが…レクイエム…だ
)}
```
### 所要時間を変更する
所要時間を変更する場合は、`duration`に数値(秒)を指定します。
```tsx
吉良吉影
僕は平穏に暮らしたいだけなんだ
```
### オフセットを変更する
オフセットを変更する場合は、`gutter`または`offset`に値を設定します。
```tsx
東方仗助
グレートだぜ
東方仗助
グレートだぜ
```
### モーダルにする
モーダルにする場合は、`modal`を`true`に設定します。スクロールブロックとフォーカストラップが有効になります。
```tsx
フーゴ・パンナコッタ
```
### 無効にする
無効にする場合は、`disabled`を`true`に設定します。
```tsx
虹村億泰
おい、仗助!
```
### 外側のクリック時に閉じない
外側のクリック時に閉じない場合は、`closeOnBlur`を`false`に設定します。
```tsx
イギー
んがくく(犬の鳴き声)
```
### ESCキーが入力された時に閉じない
ESCキーが入力された時に閉じない場合は、`closeOnEsc`を`false`に設定します。
```tsx
ディオ・ブランドー
無駄無駄無駄!
```
### 自動フォーカスを無効にする
自動フォーカスを無効にする場合は、`autoFocus`を`false`に設定します。
```tsx
岸辺露伴
```
### 初回のフォーカスを設定する
初回のフォーカスを設定する場合は、`initialFocusRef`に`Ref`を渡します。
```tsx
const inputRef = useRef(null)
return (
ナランチャ・ギルガ
)
```
### スクロールをブロックする
スクロールをブロックする場合は、`blockScrollOnMount`を`true`に設定します。
```tsx
岸辺露伴
だが断る
```
### スクロール時に閉じる
スクロール時に閉じる場合は、`closeOnScroll`を`true`に設定します。
```tsx
ギアッチョ
根掘り葉掘り聞きやがって!
```
### ネストさせる
```tsx
花京院典明
やはりエジプトか……いつ出発する?
空条承太郎
花京院
```
### 制御する
```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. |
| `animationScheme` | `"scale"` | `"none" \| "scale" \| SimplePlacement` | 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. |
| `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. |
| `defaultOpen`| - |`boolean`| If`true`, the element will be initially opened. |
| `disabled`|`false`|`boolean`| If`true`, the popover will be disabled. |
| `duration`|`0.2`|`PopupAnimationProps["duration"]`| The animation duration. |
|`elements`| - |`{
floating?: HTMLElement \| null
reference?: null \| Reference
}`| 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. |
| `gutter`|`8`|`number`| The distance or margin between the reference and popper. It is used internally to create an`offset`modifier. |
|`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 \| Middleware \| null \| undefined)[]`| 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"`|`Direction`| 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"`|`Strategy`| 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. |
|`updateRef`| - |`RefObject<() => void>`| Update the position of the floating element, re-rendering the component if required. |
|`whileElementsMounted`| - |`(reference: Reference, 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`). |
| `withCloseButton`|`true`|`boolean`| If`true`, display the popover close button. |
### 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.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. |
### 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. |
## アクセシビリティ
現在、v2の移行に伴い、このセクションは更新中です。