datui
Color scheme

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-controls and aria-haspopup="dialog"; the panel is role="dialog" by default — give it an aria-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).
  • modal traps focus inside the panel.

API

Popover

Floating panel anchored to a trigger, for arbitrary interactive content.

PropTypeDefaultDescription
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`.
arrowbooleanfalseShow an arrow pointing at the trigger.
classNamestring—
closeOnContentClickbooleanfalseClose when anything inside the panel is clicked.
crossOffsetnumber0Shift along the trigger edge in px.
defaultOpenbooleanfalse
disableCloseOnClickOutsidebooleanfalse
disableCloseOnEscapebooleanfalse
disabledbooleanfalseNever open.
hideWhenAnchorHiddenbooleanfalseHide the panel when the trigger scrolls out of view.
hoverDelaynumber | [number, number]150Hover open/close delays in ms: one number for both or `[open, close]`.
keepMountedbooleanfalseKeep the panel in the DOM (hidden) while closed.
modalbooleanfalseTrap focus inside and block outside interaction while open.
offsetnumber8Distance from the trigger in px.
onOpenChange((open: boolean) => void)—
openboolean—
placementPlacementbottom-start
rolestring"dialog"
sameWidthbooleanfalseMatch the trigger's width.
triggerPopoverTrigger | PopoverTrigger[]clickWhat opens the popover.
unstyledbooleanfalseDrop the default surface styles.