Popover()function
Popover({
children: [trigger, ...popover], //
onClose,
open = popover.flat().some(isTruthy),
}: PopoverProps): ReactElement| Param | Type | |
|---|---|---|
props | PopoverProps | Props for Popover, a trigger element that reveals floating content. required |
.children | PopoverChildren | Children for the popover. required |
.onClose | Callback | Callback that gets called when the Popover closes. |
.open | boolean | Whether the popover is open/closed (defaults to whether all popoverChildren nodes has at least one truthy node). |
| Return | |
|---|---|
ReactElement | A wrapper element containing the trigger and (when open) the popover panel. |
Trigger element that reveals a floating popover panel beside it when active or focused.
- The first
childrennode is the trigger; the rest become the popover contents. - Closes on blur away or
Escape, callingonClose.
@todo DH: Would love to use new HTML popover="auto" functionality for this but the anchor positioning it needs is not supported everywhere yet.
Examples
<Popover>{trigger}{panelContent}</Popover>