Skip to content

components/floating/Popover

import { … } from 'zidane-ui'ui/src/components/floating/Popover.tsx

Popover (click)
HoverCard (hover)
Hover me
RowActionsMenu (3-dots)
Tooltip, inline and portaled

Components#

PopoverComponent#

Renders a trigger that opens a floating surface. The caller draws the trigger from the props it receives, so any control can open one. A surface that is or holds a menu or listbox takes focus on open; Esc and a pick hand focus back to the trigger.

TypeScript
function Popover(props: PopoverProps): Element
Parameters
NameTypeDescription
propsPopoverProps

Component props.

Element
Popover props
NameTypeDefaultDescription
align?Align'start'

How the surface lines up along the trigger's edge.

ariaLabelstring

Accessible name of the surface.

children(close: () => void) => ReactNode

Renders the surface content. close closes the surface and returns focus to the trigger, for use after a pick.

className?string

Extra classes on the surface.

onDismiss?() => void

Called when an outside press, Esc or the trigger closes the surface. Not called for a close from children.

onOpenChange?(open: boolean) => void

Called when the surface opens or closes, however it does (to load what it shows on each opening).

role?'dialog' | 'listbox' | 'menu''dialog'

ARIA role of the surface, also reported on the trigger as aria-haspopup. A menu or listbox takes keyboard navigation between rows.

side?Side'top'

Preferred side of the trigger. It flips when it does not fit.

trigger(props: PopoverTriggerProps, open: boolean) => ReactNode

Renders the trigger. Spread the received props onto the element; open is whether the surface is shown.

width?number

Fixed width of the surface in px. Sized by its content when omitted.

ui/src/components/floating/Popover.tsx:83

Interfaces#

PopoverPropsInterface#

Props for Popover.

TypeScript
interface PopoverProps
PopoverProps properties
NameTypeDefaultDescription
align?Align'start'

How the surface lines up along the trigger's edge.

ariaLabelstring

Accessible name of the surface.

children(close: () => void) => ReactNode

Renders the surface content. close closes the surface and returns focus to the trigger, for use after a pick.

className?string

Extra classes on the surface.

onDismiss?() => void

Called when an outside press, Esc or the trigger closes the surface. Not called for a close from children.

onOpenChange?(open: boolean) => void

Called when the surface opens or closes, however it does (to load what it shows on each opening).

role?'dialog' | 'listbox' | 'menu''dialog'

ARIA role of the surface, also reported on the trigger as aria-haspopup. A menu or listbox takes keyboard navigation between rows.

side?Side'top'

Preferred side of the trigger. It flips when it does not fit.

trigger(props: PopoverTriggerProps, open: boolean) => ReactNode

Renders the trigger. Spread the received props onto the element; open is whether the surface is shown.

width?number

Fixed width of the surface in px. Sized by its content when omitted.

ui/src/components/floating/Popover.tsx:34

PopoverTriggerPropsInterface#

Props Popover passes to its trigger function, to spread onto the trigger element.

TypeScript
interface PopoverTriggerProps
PopoverTriggerProps properties
NameTypeDescription
aria-controls?string

The surface's id while it is open.

aria-expandedboolean

Whether the surface is open.

aria-haspopup'dialog' | 'listbox' | 'menu'

Kind of popup the trigger opens, from the role prop.

onClick() => void

Toggles the surface.

ref(node: HTMLElement | null) => void

Ref callback that registers the trigger as the surface's anchor.

ui/src/components/floating/Popover.tsx:20