Overlays
Popover
Floating panel anchored to a trigger, for arbitrary interactive content.
import { Popover } from "datui";Examples
Basic
content can be a render function receiving onClose.
Hover trigger and arrow
Accessibility
- The trigger gets
aria-expanded,aria-controlsandaria-haspopup="dialog"; the panel isrole="dialog"by default — give it anaria-label. - A click opens it and moves focus into the panel; hover and focus triggers leave focus on the trigger.
- Escape and outside clicks close it and return focus to the trigger (see
disableCloseOnEscape/disableCloseOnClickOutside). modaltraps focus inside the panel.
API
Popover
Floating panel anchored to a trigger, for arbitrary interactive content.
| Prop | Type | Default | Description |
|---|---|---|---|
| children (required) | ReactElement<unknown, string | JSXElementConstructor<any>> | — | The trigger: one element that can hold a ref. It gets `aria-expanded`, `aria-controls` and `aria-haspopup`. |
| content (required) | ReactNode | ((ctx: { onClose: () => void; }) => ReactNode) | — | Panel content, or a render function receiving `onClose`. |
| arrow | boolean | false | Show an arrow pointing at the trigger. |
| className | string | — | |
| closeOnContentClick | boolean | false | Close when anything inside the panel is clicked. |
| crossOffset | number | 0 | Shift along the trigger edge in px. |
| defaultOpen | boolean | false | |
| disableCloseOnClickOutside | boolean | false | |
| disableCloseOnEscape | boolean | false | |
| disabled | boolean | false | Never open. |
| hideWhenAnchorHidden | boolean | false | Hide the panel when the trigger scrolls out of view. |
| hoverDelay | number | [number, number] | 150 | Hover open/close delays in ms: one number for both or `[open, close]`. |
| keepMounted | boolean | false | Keep the panel in the DOM (hidden) while closed. |
| modal | boolean | false | Trap focus inside and block outside interaction while open. |
| offset | number | 8 | Distance from the trigger in px. |
| onOpenChange | ((open: boolean) => void) | — | |
| open | boolean | — | |
| placement | Placement | bottom-start | |
| role | string | "dialog" | |
| sameWidth | boolean | false | Match the trigger's width. |
| trigger | PopoverTrigger | PopoverTrigger[] | click | What opens the popover. |
| unstyled | boolean | false | Drop the default surface styles. |