Component
A floating surface anchored to a trigger. Use it for secondary content and controls that should not interrupt the current task.
- Positions against the trigger with viewport collision handling
- Escape, outside pointer press and outside focus all dismiss
- Controlled and uncontrolled open state via open, defaultOpen and onOpenChange
- Optional modal mode that traps focus while open
- Focus returns to the trigger when the popover closes
Import all parts of the component and piece them together
The root component for the Popover. Owns the open state and the parts rendered inside it.
| Prop | Type | Default |
|---|---|---|
open | boolean | -- |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | -- |
modal | boolean | false |
className | string | -- |
customRootClass | string | "" |
The button that toggles the popover open and closed.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | -- |
children | ReactNode | -- |
Renders the popover content into a portal so it escapes the trigger's overflow and stacking context.
| Prop | Type | Default |
|---|---|---|
children | ReactNode | -- |
container | Element | null | -- |
forceMount | boolean | false |
The floating surface. Positions itself against the trigger and owns dismissal behaviour.
| Prop | Type | Default |
|---|---|---|
aria-label | string | -- |
aria-labelledby | string | -- |
side | "top" | "right" | "bottom" | "left" | "bottom" |
sideOffset | number | 0 |
align | "start" | "center" | "end" | "center" |
alignOffset | number | 0 |
avoidCollisions | boolean | true |
collisionPadding | number | 0 |
collisionBoundary | Element | null | Array<Element | null> | -- |
arrowPadding | number | 0 |
sticky | "partial" | "always" | "partial" |
hideWhenDetached | boolean | false |
forceMount | boolean | false |
asChild | boolean | false |
onOpenAutoFocus | (event) => void | -- |
onCloseAutoFocus | (event) => void | -- |
onEscapeKeyDown | (event: KeyboardEvent) => void | -- |
onPointerDownOutside | (event) => void | -- |
onFocusOutside | (event) => void | -- |
onInteractOutside | (event) => void | -- |
Closes the popover and returns focus to the trigger.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | -- |
children | ReactNode | -- |
An optional pointer that tracks the trigger. Render it inside Content.
| Prop | Type | Default |
|---|---|---|
className | string | -- |
width | number | -- |
height | number | -- |
Positions the popover against a specific element instead of the trigger.
| Prop | Type | Default |
|---|---|---|
className | string | -- |
children | ReactNode | -- |
| Shortcut | Description |
|---|---|
Escape | Closes the popover and returns focus to the trigger. |
Tab | Moves focus to the next focusable element inside the popover content. |
Shift + Tab | Moves focus to the previous focusable element inside the popover content. |
| Reference | What Rad UI follows |
|---|---|
Content uses dialog semantics with labelling, focus containment and dismiss behaviour. |