Components · Overlays
Popover
A small panel that opens next to the element people click, for a little input such as a choice, a field and a button.
import { Popover } from "@botiverse/raft-ui";A popover is a small panel that opens next to the element people click and holds a little input: a choice of a few options, a field, a button. Snoozing a notification or renaming something fits in one. It closes on a click outside or Esc.
When to use
Which overlay fits which job is in Choosing a component.
Anatomy
Popover: the root. Owns the open state. Required.PopoverTrigger: the element that opens it. Required.PopoverContent: the panel, portaled and positioned next to the trigger, a column of its parts.size="item"makes it a popover about an app's item (About an item). Required.PopoverHeader: a row withPopoverTitleand an optionalPopoverClose.PopoverTitleandPopoverDescription: the title and a helper sentence under it.PopoverDescriptiontakes only aHelperText, made withhelperText(content, { why, about }), and renders itswhyandaboutasdata-whyanddata-about, and is only for a consequence (consequence), who sees it or whom it affects (audience), or how to recover (recovery) (Writing › Helper text); a status ("No comments yet") or data is body text.PopoverBody: the panel's text, aPopoverTitleand aPopoverDescription, or a list, 16px in from its edges (12px in a popover about an item). It is the part that scrolls when the panel runs out of room (A long popover). Experimental, from@botiverse/raft-ui/wip.PopoverActions: the panel's buttons at its end, underPopoverBody: the way out first, then the confirm button. Experimental, from@botiverse/raft-ui/wip.PopoverSeparator: a hairline between parts of the panel.PopoverClose: a button that closes the popover.PopoverArrow: an optional pointer toward the trigger, on whichever side the panel opens (inline-startandinline-endfollow the direction Base UI placed the panel by, itsDirectionProvider,ltrwithout one; a right-to-left page sets it, as for every Base UI part). The panel clips what overflows it, so a panel with an arrow lets it overflow (overflow-visible), as CoachMark does.PopoverBackdrop: a transparent layer behind the panel that catches clicks outside it.PopoverPortal,PopoverViewportandPopoverPopup: lower-level parts.PopoverPopupis the panel surface without positioning.isInsideOverlay(node): whether a node is inside a raft-ui overlay, this popover or any other;closestOverlay(node): that overlay's portal container (Inside an overlay).PortalContainerProviderandusePortalContainer(): where every raft-ui overlay under the provider renders, for a part of the app drawn in another window (Rendering in another window).useOverlayPortalNode(): the element an overlay opened at this place in the tree would render in, for a layer of the app's own that must stack with raft-ui's overlays (A layer of your own).
Behavior
- The popover opens below its trigger, aligned to its start edge, and moves or flips when it meets the window edge (Elevation). A popover with a
PopoverBodyis a list popup: it stays below and scrolls its body as long as five rows fit there (A long popover). - In a phone sheet or a drawer it stays under the sheet's head, unless its trigger is in the head;
collisionBoundary="clipping-ancestors"opts it out (Dialog). - The popover keeps clear of the frame insets: where a shell keeps part of the window for itself (
--raft-frame-inset-top,--raft-frame-inset-start,--raft-frame-inset-end), it stops 8px from that part, not from the window's edge. The start and end insets are the corners of the top band, so they count only when its trigger is in the band; under it, it keeps its own padding from the window's edge (Page structure). The web sets none. - The popover follows its trigger while the window or any ancestor pane scrolls or resizes, and closes (returning focus to the trigger when it is still on the page) if the trigger scrolls out of its clipping region or leaves the page (Elevation).
- A click outside and Esc close it. A Cancel button closes it too. A click into an embedded frame (an
<iframe>, cross-origin too) outside the panel counts as a click outside; one into a frame inside the panel doesn't. A tour's CoachMark, built on these parts, is the exception: a click outside leaves it open (Coach marks). - It has no scrim; the page behind it stays as it is.
- A popover longer than the room it has keeps its header and its actions and scrolls its body between them (A long popover).
A long popover
A popover that lists something with no fixed length, such as who has read a document, can be taller than the room it has. It never runs past the window, and its header and buttons never scroll away.
- The panel stays on the side it opens on and shrinks to the room there, as long as that room holds five rows (
--popup-list-min-height, 178px with a mouse). Only with less does it flip to the other side, and it opens beside its trigger only when neither side holds five rows (Elevation). Its whole length doesn't have to fit: the readers of a document under their count stay under it in any window and scroll. A popover without aPopoverBody(one of its own parts that don't scroll) flips whole instead, as before. - The panel is as tall as its parts, up to the room the positioner leaves it (
--available-height, less 4px). Past that,PopoverBodyscrolls: it is a ScrollArea that shrinks, whilePopoverHeader,PopoverSeparatorandPopoverActionskeep their height. The panel's title says what the list is and its buttons act on it, so both stay in view however far the list is scrolled. - The body's cut edges fade, over up to 24px toward an edge with more past it (Edges fade).
- Overflowing, the body is a tab stop, so a keyboard can scroll it. When it holds a list rather than text, name it:
role="region"and anaria-label. classNameonPopoverBodyis its content's, its inset and gap, as it was before the body scrolled;scrollClassNameis the scroller's. The scroller clips what its content draws past its box, so a body that does that and never needs to scroll (a panel that is itself a marker, in anoverflow-visiblepopup) passesscrollClassName="overflow-visible".- Put the whole list in one
PopoverBody. A panel of your own parts is a flex column: a ScrollArea in it shrinks by itself; givemin-h-0to any box between the panel and the ScrollArea, so it can shrink too. - A popover that keeps growing, or that people stay in, is a Drawer instead.
Inside an overlay
The panel is portaled out of the tree it was opened from, so region.contains(event.target) is false for a press in it, even when the popover belongs to the region. Where a handler of the page's own must leave the overlays' events alone (a shortcut on the page, a press outside a region that closes it, a drag that starts in a row), ask isInsideOverlay(event.target) from @botiverse/raft-ui: it is true for a node inside any raft-ui overlay (a popover, a menu, a select list, a combobox, a tooltip, a preview card, the notification center, a dialog, an alert dialog, a drawer, a lightbox or a toast), and false for a node of the page and for null. A text node counts by its parent element.
- Where the handler needs the overlay itself, not only whether there is one, ask
closestOverlay(event.target): the portal container of the innermost overlay the node is in, ornull. For example,closestOverlay(target)?.contains(region)tells whether a press in an overlay is in the same overlay as a region the page draws in it. - Every
…Portalpart marks its container withdata-raft-ui-overlay, and an overlay opened from another is portaled into that one's container, so it is inside both. Read it throughisInsideOverlay, never Base UI's own[data-base-ui-portal], which is internal to Base UI. - An overlay given a
containerof the page's own is still inside its portal container. A portal of the app's own (createPortal) andDragLift's copy are not overlays.
Rendering in another window
Base UI portals every overlay to the global document.body, the body of the window whose script runs. A part of the app drawn in a second window, such as a Raft Desktop window opened with window.open("about:blank") and filled with createPortal from the main window's React tree, would open its popovers, menus, tooltips and dialogs in the main window. Wrap that part in PortalContainerProvider, inside the createPortal, with an element of the second window's document:
createPortal(
<PortalContainerProvider container={auxWindow.document.body}>
<SecondWindowContent />
</PortalContainerProvider>,
auxWindow.document.body,
);- Every raft-ui overlay under it renders in that element: Popover, DropdownMenu, ContextMenu, Tooltip, PreviewCard, Select, Combobox, ComboboxSelect, NotificationCenter, Dialog, AlertDialog, Drawer, Lightbox, a
ToastProvider's viewport,DragLiftandDragRefusalHint. With no provider nothing changes: they render in the page's body. - Each overlay decides in this order: the
container(orportalProps.container, aToastProvider'sportalContainer) passed to it, then an overlay it is opened inside (Base UI renders it in that one's portal, as without a provider, so it stays inside it), then the provider's container, then the page's body. container={null}means the element doesn't exist yet: an overlay opened then renders nothing until it does, instead of opening in the wrong window.- What the overlays measure or listen to follows the document they render in: the window's size and frame insets (
--raft-frame-inset-*, read on that document's root element), its visual viewport, its media queries (where a dialog becomes a phone sheet), the on-screen keyboard, a press outside, focus, and the keys a coach mark or a lightbox takes. Base UI's own dismissal, scroll lock and focus return already follow the popup's document. - The components that measure themselves or wait for a frame work in the second window too, and keep running while the main window is hidden (a hidden window stops its animation frames, throttles its timers and stops reporting its resize observers): ScrollArea's scroll bars, VirtualList, CommentMargin and
setCommentHighlights(registered in the passages' own window), Ellipsis,useTruncatedand thetitlea field gives a cut value, a Dialog's and an AlertDialog's footer stacking, DescriptionList and MessageActionCard deciding where labels go, SegmentedControl, ComboboxSelect, FitToolbar and BannerAction. Each takes its frames, timers, observers, focus, selection, fonts and key listeners from the window of the element it is about. - For the page's own elements that window is the global
window. A consumer test that stubsrequestAnimationFrame,ResizeObserveror a timer must stub it onwindow: underglobal-jsdomwindowis notglobalThis, and a stub set only onglobalThisis not seen (the test fails, or passes without its stub). - A toast raised in the second window shows there only through a
ToastProviderof its own inside the subtree (Toast). usePortalContainer()returns the provider's container (undefinedwith no provider), for a portal of the app's own that must follow the same rule:createPortal(node, usePortalContainer() ?? document.body).- The second window's document needs raft-ui's styles of its own (
styles.css, with the theme), as any document does: an overlay carries its theme class (lightordark), not the stylesheet.
A layer of your own
A layer the app draws itself over the page, such as an invisible backdrop that closes a hand-rolled menu on a click outside, stacks with raft-ui's overlays only when it is in the same parent as them. Overlays share their z-index, so DOM order decides which is drawn on top. Inside a dialog, Base UI puts a menu opened there in the dialog's portal, but a createPortal(backdrop, document.body) lands after the dialog, on top of it and of the menu, which then can't be clicked (Scout, 2026-11-30, #proj-raft-ui:759af4e3; #triage:#711). Render the layer in useOverlayPortalNode() instead:
const node = useOverlayPortalNode();
return node && createPortal(<div className="fixed inset-0 z-popup" onPointerDown={close} />, node);- It returns the element a raft-ui overlay opened at the same place would render in: inside a Popover, a menu, a select list, a combobox, the notification center, a dialog, an alert dialog, a drawer or a lightbox, that overlay's portal container; else the
PortalContainerProvider's container (nullwhile it doesn't exist yet); elsedocument.body. - It decides from the React tree, as Base UI does, not from the DOM: a
createPortalout of a dialog's element is still inside the dialog. A tooltip, a preview card and a toast don't count: Base UI doesn't put the overlays opened in them in their portal either. - Only overlays rendered through raft-ui count. One rendered with
@base-ui/reactdirectly is not seen.
Content
- Write button labels in sentence case, with the confirm button repeating the verb: Snooze, Rename (Writing).
Accessibility
- Popover wraps the Base UI Popover. It provides the
dialogrole on the panel, moves focus into it on open, and returns focus to the trigger on Esc. - Name the panel:
PopoverTitlelabels it. Without a visible title, put anaria-labelonPopoverContent. - Give an icon-only trigger an
aria-label.
Rules
- Make a popover 300px wide, with 16px padding. A popover about an app's item is the exception (
size="item", About an item). - Don't put a pink button in a popover. Confirm with an ink-border button (
variant="outline") and cancel withvariant="ghost": a popover is a small step, not the screen's primary action. The one exception is a tour's CoachMark, whose Next and Done are pink: at that moment it is the one thing to do (Coach marks).
About an item
A popover about an app's item, such as the question an app's link asks before it shows its previews (PreviewCard), takes size="item": it is 400px wide, and PopoverBody, PopoverTitle and PopoverActions take the parts of a card in a message, with its 12px inset and text-subhead title. It stands in for the item card the chip opens once the reader allows the app, so it looks like that card, not like the other popovers (stdrc, 2026-11-10): a popover belongs to the family of what it is about (Cards in messages). Every other popover, one with a field, a choice or a short confirmation, keeps 300px and 16px: it is a small step of its own, not an item.
API
Popover
PopoverArrow, PopoverBackdrop
Also takes the attributes of its element.
PopoverClose
Also takes the attributes of its element.
PopoverContent
Also takes the attributes of its element.
PopoverDescription
Also takes the attributes of its element.
PopoverHeader, PopoverPopup
Takes the attributes of its element.
PopoverPortal
Also takes the attributes of its element.
PopoverSeparator
Takes the attributes of its element.
PopoverTitle
Also takes the attributes of its element.
PopoverTrigger
Also takes the attributes of its element.
PopoverViewport
Also takes the attributes of its element.
PopoverActions
Takes the attributes of its element.
PopoverBody
Also takes the attributes of its element.
Related
Changes
- 0.106.2 · ChangedList popups shrink and scroll on their side before flipping; the side axis is the last resort ([Elevation › Popups](https://raft-design.botiverse.build/foundations/elevation/#popups), [DropdownMenu › Long menus](https://raft-design.botiverse.build/components/dropdown-menu/#long-menus), [Popover › A long popover](https://raft-design.botiverse.build/components/popover/#a-long-popover)):
DropdownMenuContent,SelectContent,ComboboxContent, ComboboxSelect on a desktop and aPopoverContentwith aPopoverBodystay on the side they open on and shrink to the room there, scrolling their list, as long as it holds five rows (--popup-list-min-height: 178px with a mouse, 188px on a touch screen). With less they flip to the other side, and they open beside the trigger only when neither side holds five rows. - 0.106.0 · Design SystemLong menus and popovers scroll inside the room they have ([DropdownMenu › Long menus](https://raft-design.botiverse.build/components/dropdown-menu/#long-menus), [Popover › A long popover](https://raft-design.botiverse.build/components/popover/#a-long-popover), [Elevation › Popups](https://raft-design.botiverse.build/foundations/elevation/#popups)): a popup is capped at the space left between its trigger and the window's edge, and what doesn't fit scrolls inside it, never clipped. The highlighted item of a menu stays in view and clear of the fade; the cut edges fade over up to 24px; an action on the whole list stays below the items (
DropdownMenuPinnedFooter); a popover keeps its header and buttons and scrolls its body. Changed in this release:DropdownMenuContent,ContextMenuContent,PopoverContent,PopoverBody,PreviewCardContent,PreviewCardBody. - 0.106.0 · ChangedPopoverContent, PreviewCardContent: the panel is a flex column (
flex flex-col), andPopoverHeader,PopoverSeparator,PopoverActions,PreviewCardHeader,PreviewCardSeparator,PreviewCardSubtitle,PreviewCardActionsandPreviewCardFooterdon't shrink. PopoverBody and PreviewCardBody are a ScrollArea (min-h-0, faded edges,overscroll="contain"): they scroll when the panel is capped, and are a tab stop while they overflow. - 0.103.4 · FixedFrame insets (
Popover,DropdownMenu,ContextMenu,Select,Combobox,ComboboxSelect,Tooltip,PreviewCard,CoachMark,NotificationCenter,MobileNavServerPopover,ToastPositioner,ComposerSuggestionList):--raft-frame-inset-startand--raft-frame-inset-endare the corners of the window's top band (--raft-frame-inset-top), not columns down its sides. A popup anchored under the band keeps its own padding from the window's edge; only one anchored in the band (a title-bar control, or a context menu opened in the bar) keeps 8px clear of a corner. - 0.103.3 · FixedFrame insets (
useFrameInsets,frameCollisionBoundary): opening a positioned popup (Popover,DropdownMenu,Select,Combobox,ComboboxSelect,ContextMenu,Tooltip,PreviewCard,NotificationCenter,MobileNavServerPopover,ComposerSuggestionList) no longer stalls the main thread when--raft-frame-inset-*holds acalc()orenv(titlebar-area-*)expression on an overlay title bar. - 0.103.0 · Breaking ChangesExplanation slots take only a
HelperText:FieldDescription,FormSection'sdescription, aChoiceListitem'sdescription,SelectItemDescription,DialogDescription,AlertDialogDescription,DrawerDescription,PopoverDescription,EmptyStateDescription,CardDescription,CardFooter,BannerDescription,DialogFooterNote(work in progress),MessageActionCardHint,MessageActionCardHeaderDescription,MessageActionCardScopeDescriptionandMessageActionCardActionsNote. AHelperTextis made only byhelperText(content, { why, about }):contentis anyReactNode(a string, a formatted message, aTextLinkinside a sentence),whyis"consequence","audience"or"recovery", andaboutnames the thing the line is about. Each slot renders the content withdata-whyanddata-about, and in development warns once when it is given anything else, which it still renders.ToastDescription,NotificationCenterItemBody,EmptyStateTitle,ListRowDescriptionand the status and data parts are unchanged. - 0.102.0 · Added
CoachMark, one stop of a tour (work in progress, from@botiverse/raft-ui/wip; [CoachMark](https://raft-design.botiverse.build/components/coach-mark/), [Coach marks](https://raft-design.botiverse.build/patterns/coach-marks/)).CoachMarktakes the stop'sanchor,openandonDismiss;CoachMarkContentis the 300px bubble with an arrow, 8px from its target;CoachMarkAction,CoachMarkActions,CoachMarkCountandCoachMarkNext(the pink Next or Done) lay out its rows, withPopoverBody,PopoverTitleandPopoverDescriptionfor the text. While a stop is open its target holds the Located wash (data-located="held"). The bubble is non-modal: a press outside and focus leaving don't close it, focus goes to Next when a stop opens unless the person is typing in a field, its buttons come right after its target in the Tab order, and Esc in the bubble (or aPopoverClose) callsonDismiss, while Esc anywhere else goes on to what has focus. - 0.102.0 · Fixed
PopoverArrowandPreviewCardArrowpoint at their trigger on every side ([Popover › Anatomy](https://raft-design.botiverse.build/components/popover/#anatomy)). They sat at the panel's top whichever side it opened on, so they pointed the right way only for a panel below its trigger; they now sit on the edge facing the trigger, with the seam on their two outer edges, andinline-startandinline-endfollow the writing direction.