Popover

A click-triggered, non-modal floating panel anchored to its trigger. Focus moves in on open but is never trapped; Escape and outside clicks close it.

Installation

npx dafink-ui add popover

Demo

Props

NameTypeDefaultDescription
triggerReactNode-Content of the built-in trigger button.
childrenReactNode | ((close: () => void) => ReactNode)-Panel content. Pass a function to receive close, which closes the panel and returns focus to the trigger.
side'top' | 'right' | 'bottom' | 'left''bottom'Which side of the trigger the panel appears on.
align'start' | 'center' | 'end''center'Alignment along the chosen side.
labelstringundefinedAccessible name for the panel (aria-label).
onOpenChange(open: boolean) => voidundefinedCalled whenever the popover opens or closes.
disabledbooleanfalseDisables the trigger.
classNamestring''Additional classes on the panel.
triggerClassNamestring''Additional classes on the trigger button.
triggerPropsButtonHTMLAttributes<HTMLButtonElement>-Extra attributes for the trigger button, e.g. aria-label for an icon-only trigger.
unstyledTriggerbooleanfalseDrops the built-in trigger styles so triggerClassName fully defines the trigger.

Accessibility

Popover is a non-modal floating panel (role="dialog", no aria-modal) with no focus trap. On open, focus moves to the first focusable element inside the panel (or the panel itself if empty). Tab is never intercepted: it walks through the panel's own content, and once focus leaves the panel entirely (Tab, Shift+Tab, or an outside click) a blur/pointerdown handler closes it without pulling focus back. Escape is the one path that both closes it and returns focus to the trigger.

KeyFunction
escapeCloses the popover and returns focus to the trigger.
tabMoves through the panel's focusable content; once focus leaves the panel it closes without stealing focus back.
shift+tabSame as Tab, in reverse.
enterToggles the popover from the trigger button (native activation).