Skip to content

Popover

Popover shows a floating panel next to its trigger. It is the base of every pop-up component in raft-ui (Tooltip, Popconfirm, Popselect, Dropdown). Positioning, dismissal and nesting come from Floating UI.

Demos

Trigger

trigger is hover (the default), click, focus or manual. A hover popover also opens on focus for keyboard users and on tap on touch screens. manual opens and closes only through show.

Placement

Twelve placements: a side, then -start or -end to align with that edge of the trigger. Without room the popover flips to the other side (flip={false} turns that off) and shifts to stay on screen.

header and footer add rows above and below the content, divided by a line. When the popover is capped (by the room it has, or a maxBlockSize in contentStyle), only the content scrolls, with ScrollArea’s scrollbar; the header and footer stay put.

Arrow and width

showArrow={false} drops the arrow. width sets a width in px, or trigger to match the trigger.

Nested

A popover opened from inside another one belongs to it: clicking the inner popover doesn’t close the outer one, and Escape closes the innermost first.

At a point

With x and y the popover opens at a viewport point and needs no trigger, for context menus and the like.

Raw

raw drops the surface (background, border, padding, arrow) and keeps positioning and motion, for content that draws its own.

Near the edges

Wherever the trigger sits, the popover stays on screen and never adds scrollbars to the page: it flips to the other side (or across, when neither fits), slides along the edge while the arrow keeps pointing at the trigger, and when it is bigger than the room it has, its content scrolls. Try the four corners of this box, and resize the window.

Props

NameTypeDefaultDescriptionVersion
childrenReactElement | stringundefinedThe trigger: one element, which receives the popover’s ref and handlers. Text is wrapped in a span.Unreleased
contentReactNode | () => ReactNodeundefinedThe popover’s content. A function is only called while the popover renders.Unreleased
headerReactNodeundefinedA row above the content.Unreleased
footerReactNodeundefinedA row below the content.Unreleased
triggerhover | click | focus | manualhoverWhat opens it.Unreleased
showbooleanundefinedControlled visibility.Unreleased
defaultShowbooleanfalseInitial visibility when uncontrolled.Unreleased
onUpdateShow(show: boolean) => voidundefinedCalled when the popover wants to open or close.Unreleased
placementPopoverPlacementtopSide and alignment.Unreleased
delaynumber100Milliseconds before a hover opens it.Unreleased
durationnumber100Milliseconds before leaving closes it.Unreleased
keepAliveOnHoverbooleantrueStay open while the pointer moves onto the popover.Unreleased
showArrowbooleantrueShow the arrow.Unreleased
flipbooleantrueFlip to the other side when there is no room.Unreleased
widthnumber | 'trigger'undefinedWidth in px, or the trigger’s width.Unreleased
x / ynumberundefinedOpen at a viewport point instead of next to the trigger.Unreleased
disabledbooleanfalseNever open.Unreleased
tostring | HTMLElement | falseundefinedWhere to mount. Defaults to ConfigProvider’s portalContainer, then document.body; false renders in place.Unreleased
zIndexnumberundefinedA fixed z-index. By default each layer stacks above the ones opened before it.Unreleased
rawbooleanfalseDrop the built-in surface.Unreleased
keepMountedbooleanfalseKeep it in the DOM, hidden, after it closes.Unreleased
onClickoutside(event: Event) => voidundefinedCalled on a press outside the trigger and the popover.Unreleased
contentClassNamestringundefinedClass of the popover surface.Unreleased
contentStyleCSSPropertiesundefinedStyle of the popover surface.Unreleased

Any other prop, and ref, goes to the trigger, merged with the trigger’s own (event handlers both run). That is also how popovers nest on one element: an outer popover’s handlers pass through the inner one.

The popover is a non-modal dialog linked to its trigger with aria-expanded and aria-controls. While open it stacks above every layer opened before it; the theme follows it into the portal.