--- title: NativePopover description: "`NativePopover` is a component that floats around an element to display information using the HTML Popover API." links: - style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/native-popover/native-popover.style.ts - source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/native-popover - storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-native-popover--basic --- # NativePopover `NativePopover` is a component that floats around an element to display information using the HTML Popover API. ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` :::note `NativePopover` uses the HTML Popover API, which provides better performance and accessibility compared to the [Popover](https://yamada-ui.com/docs/components/popover.md). However, it requires browser support for the Popover API. ::: ## Usage ```tsx import { NativePopover } from "@yamada-ui/react" ``` ```tsx import { NativePopover } from "@/components/ui" ``` ```tsx import { NativePopover } from "@workspaces/ui" ``` ```tsx ``` :::tip To control the open state or customize animations, use [Popover](https://yamada-ui.com/docs/components/popover.md). ::: :::tip To display supplementary information without interactive elements, use [Tooltip](https://yamada-ui.com/docs/components/tooltip.md). ::: :::tip To temporarily restrict interaction while requesting confirmation or input, use [Modal](https://yamada-ui.com/docs/components/modal.md). ::: ### Change Size ```tsx {(size) => ( ベジータ! がんばれカカロット……お前がナンバー1だ!! )} ``` ### Add Footer ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! 第280話 ``` ### Close Trigger You can add a close button inside the popover using `NativePopover.CloseTrigger`. ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` ### Display Popover on Different Element To display a popover on a different element, use `NativePopover.Anchor`. ```tsx
Display Popover Here
ベジータ! がんばれカカロット……お前がナンバー1だ!!
``` ### Change Placement To change the placement, set `placement` to `"start"`, `"end-end"`, etc. By default, `"end"` is set. ```tsx {(placement) => ( ベジータ! がんばれカカロット……お前がナンバー1だ!! )} ``` ### Change Offset To change the offset, set `gutter` or `offset` to a value. ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` ### Popover Modes The HTML Popover API supports different [modes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/popover#value) for controlling popover behavior. This is a key feature that distinguishes `NativePopover` from the `Popover` component. ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ベジータ! がんばれカカロット……お前がナンバー1だ!! ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` ### Disable To disable the popover, set `disabled` to `true`. ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` ### Nest Popovers ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` ## Props ### NativePopover.Root | Prop | Default | Type | Description | | -------------------------------- | ------------------------------------------------------ | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | `size` | `"md"` | `"lg" \| "md" \| "sm" \| "xs"` | The size of the component. | | `autoUpdate` | `true` | `boolean` | If `true`, automatically updates the position of the floating element when necessary. | | `disabled` | `false` | `boolean` | If `true`, the popover will be disabled. | | `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. | | `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. | | `offset` | - | `[number, number]` | The main and cross-axis offset to displace popper element from its reference element. | | `open` | `true` | `boolean` | Whether the popper should be enabled. | | `placement` | `"end"` | `UsePopperProps["placement"]` | The placement of the popper relative to its reference. | | `platform` | - | `Platform` | Custom or extended platform object. | | `popover` | `"auto"` | `"" \| "auto" \| "hint" \| "manual" \| true` | The mode of the popover. | | `popoverTarget` | - | `string` | The target element ID for the popover trigger. If not provided, a generated ID will be used. | | `popoverTargetAction` | `"toggle"` | `"hide" \| "show" \| "toggle"` | The action for the popover target. | | `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. | | `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`). | ### NativePopover.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. | ### NativePopover.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. | ### NativePopover.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. | ### NativePopover.Content | 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. | ### NativePopover.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. | ### NativePopover.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. | ### NativePopover.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 ### Keyboard Navigation | Key | Description | State | | -------- | ------------------- | ---------------------------------- | | `Escape` | Closes the popover. | `popover="auto"`, `popover="hint"` | ### ARIA Roles and Attributes | Element | Roles and Attributes | Usage | | ----------------------------------- | ------------------------ | ----------------------------------------------------------------- | | `div.ui-native-popover__content` | `role="dialog"` | Indicates that it is a dialog. | | | `id` | Used to associate with `button.ui-native-popover__trigger`. | | | `aria-labelledby` | Sets the `id` of the associated `div.ui-native-popover__header`. | | | `aria-describedby` | Sets the `id` of the associated `div.ui-native-popover__body`. | | `button.ui-native-popover__trigger` | `role="button"` | Indicates that it is a button. | | | `aria-haspopup="dialog"` | Indicates that it triggers a dialog. | | | `aria-controls` | Sets the `id` of the associated `div.ui-native-popover__content`. | | | `aria-disabled` | Sets to `"true"` when `disabled={true}`. | | `div.ui-native-popover__header` | `id` | Used to associate with `div.ui-native-popover__content`. | | `div.ui-native-popover__body` | `id` | Used to associate with `div.ui-native-popover__content`. | ## Similar Components - [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. - [Popover](https://yamada-ui.com/docs/components/popover.md): `Popover` is a component that floats around an element to display information. - [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. - [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. - [Indicator](https://yamada-ui.com/docs/components/indicator.md): `Indicator` is a component that displays at the corner of elements such as avatars. ## Used By Components & Hooks - [Popover](https://yamada-ui.com/docs/components/popover.md): `Popover` is a component that floats around an element to display information.