An accessible popup anchored to a trigger button.
import { Popover } from '@ontoui/react';
<Popover.Trigger>Open popover</Popover.Trigger>
<Popover.Title>Title</Popover.Title>
<Popover.Description>Description</Popover.Description>
<Popover.Close>Close</Popover.Close>
The Popover compound component is made up of the following parts:
| Part | Description |
|---|
Popover.Root | Root context provider. Manages open state. |
Popover.Trigger | Button that opens the popover. |
Popover.Popup | The popup panel. Renders into a portal, positioned to the trigger. |
Popover.Title | Accessible heading that labels the popover. |
Popover.Description | Supporting text associated with the popover. |
Popover.Close | Button that closes the popover. |
Control which side the popover appears on using the side prop on Popover.Popup.
<Popover.Trigger>top</Popover.Trigger>
<Popover.Popup side="top">
<Popover.Title>Opens on top</Popover.Title>
<Popover.Close>Close</Popover.Close>
| Prop | Type | Default |
children? | ReactNode | — |
open? | boolean | — |
onOpenChange? | (open: boolean) => void | — |
defaultOpen? | boolean | — |
| Prop | Type | Default |
children? | ReactNode | — |
className? | string | — |
render? | ReactElement<unknown, string | JSXElementConstructor<any>> | <Button.Root variant="secondary" /> |
| Prop | Type | Default |
children? | ReactNode | — |
className? | string | — |
side? | "top" | "right" | "bottom" | "left" | bottom |
sideOffset? | number | 8 |
ref? | Ref<HTMLDivElement> | — |
| Prop | Type | Default |
children? | ReactNode | — |
className? | string | — |
ref? | Ref<HTMLDivElement> | — |
| Prop | Type | Default |
children? | ReactNode | — |
className? | string | — |
ref? | Ref<HTMLDivElement> | — |
| Prop | Type | Default |
children? | ReactNode | — |
className? | string | — |
render? | ReactElement<unknown, string | JSXElementConstructor<any>> | <Button.Root variant="secondary" /> |
ref? | Ref<HTMLDivElement> | — |