Popover
Popover provides a styled actionable popup. It exports 3 components that combine to create our popover. The Popover.Trigger renders a <button> by default, but this can be overridden with the asChild prop, which will instead add all the functional and accessibility requirements to the child component instead (see the below example).
Also, note that the component must accept a ref.
Read more about the underlying UI component on the Radix UI documentation site.
<Popover>
<Popover.Trigger asChild>
<Button>Click me</Button>
</Popover.Trigger>
<Popover.Content>
<Heading size="xs" className="mb-3">
Popover
</Heading>
<Text size="sm">
The "Popover" can display any type of element as a trigger and has the content hidden by default
</Text>
</Popover.Content>
</Popover>
API Reference
| Prop | Type | Default | Required |
|---|---|---|---|
defaultOpen | boolean | - | - |
modal | boolean | - | - |
onOpenChange | (open: boolean) => void | - | - |
open | boolean | - | - |
| Prop | Type | Default | Required |
|---|---|---|---|
align | "center" | "start" | "end" | - | - |
alignOffset | number | - | - |
arrowPadding | number | - | - |
as | JSX.IntrinsicElements | - | - |
asChild | boolean | - | - |
avoidCollisions | boolean | - | - |
closePopoverText | string | Close popover | - |
collisionBoundary | null | Element | Boundary[] | - | - |
collisionPadding | number | Partial<Record<"left" | "right" | "top" | "bottom", number>> | - | - |
forceMount | true | - | - |
hideWhenDetached | boolean | - | - |
onCloseAutoFocus | (event: Event) => void | - | - |
onEscapeKeyDown | (event: KeyboardEvent) => void | - | - |
onFocusOutside | (event: FocusOutsideEvent) => void | - | - |
onInteractOutside | (event: FocusOutsideEvent | PointerDownOutsideEvent) => void | - | - |
onOpenAutoFocus | (event: Event) => void | - | - |
onPointerDownOutside | (event: PointerDownOutsideEvent) => void | - | - |
showCloseButton | boolean | | - |
side | "left" | "right" | "top" | "bottom" | top | - |
sideOffset | number | 8 | - |
size | "sm" | "md" | "lg" | md | - |
sticky | "partial" | "always" | - | - |
updatePositionStrategy | "always" | "optimized" | - | - |