--- 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 --- ```tsx ベジータ! がんばれカカロット……お前がナンバー1だ!! ``` :::note `NativePopover` uses the HTML Popover API, which provides better performance and accessibility compared to the [Popover](https://yamada-ui.com/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 ``` ### 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だ!! ``` ## Used By Components & Hooks ## 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"` | `Direction` | 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. |