Popover
A non-modal popup anchored to a trigger: Popover.Trigger (merges its props onto the child button) and Popover.Content (portaled, positioned role="dialog" surface). Use it for custom popups such as filters or details; for a menu button use Menu.Trigger and Menu.Popover, which add menu semantics and keyboard support.
Controlled (open/onOpenChange) or uncontrolled (defaultOpen); side/align place the content, and ignoreOutsideRefs lists external elements (such as a toggle button) whose presses do not dismiss it.
- **Hover cards:** openOnHover opens it when a mouse pointer rests on the trigger (openDelay) and closes it once the pointer has left the trigger and the content (closeDelay), unless focus is inside; a click on the trigger pins it.
- **Context popovers:** openOnContext makes the trigger a context-menu region: a right click opens it at the pointer, Shift+F10 or the ContextMenu key at the focused row (with focus moving into the content). Name the content with title or aria-label.
- **Custom anchors:** target places it at another element or at a VirtualElement (a point, a text selection); with a controlled open it needs no trigger.
- **Motion:** the content fades and slides in from its trigger and back out as it closes; Popover.Content's motion turns it off or replaces it.
Examples
Default
export const Default: Story = {};Labelled By Trigger
export const LabelledByTrigger: Story = {
args: {
children: (
<>
<Popover.Trigger>
<Button>Filters</Button>
</Popover.Trigger>
<Popover.Content>
<p style={{ margin: 0 }}>Choose which items to show.</p>
</Popover.Content>
</>
),
},
};Icon Only Trigger
export const IconOnlyTrigger: Story = {
args: {
children: (
<>
<Popover.Trigger>
<Tooltip content="Filters" relationship="label">
<Button icon={<FilterIcon />} />
</Tooltip>
</Popover.Trigger>
<Popover.Content>
<p style={{ margin: 0 }}>Choose which items to show.</p>
</Popover.Content>
</>
),
},
};Placement
export const Placement: Story = {
args: {
side: 'top',
align: 'center',
},
};Controlled
export const Controlled: Story = {
render: ({ onOpenChange, ...args }) => {
const [open, setOpen] = React.useState(false);
const toggleRef = React.useRef<HTMLButtonElement>(null);
const change = (next: boolean) => {
setOpen(next);
onOpenChange?.(next);
};
return (
<div style={{ display: 'flex', gap: 8, alignItems: 'start' }}>
<Popover open={open} onOpenChange={change} ignoreOutsideRefs={[toggleRef]} {...args}>
<Popover.Trigger>
<Button appearance="primary">Toggle Popover</Button>
</Popover.Trigger>
<Popover.Content title="Controlled popover">
<p style={{ margin: 0 }}>This popover is controlled via state.</p>
<Button
appearance="subtle"
size="small"
onClick={() => change(false)}
style={{ marginTop: 8 }}
>
Close
</Button>
</Popover.Content>
</Popover>
<Button ref={toggleRef} appearance="subtle" onClick={() => change(!open)}>
External Toggle
</Button>
</div>
);
},
};Hover Card
export const HoverCard: Story = {
args: {
openOnHover: true,
children: (
<>
<Popover.Trigger>
<Button appearance="transparent">Maria Lopez</Button>
</Popover.Trigger>
<Popover.Content title="Maria Lopez">
<div className="flex items-center gap-3">
<Avatar name="Maria Lopez" size="large" />
<span className="text-wave-muted-foreground">Product designer, Oslo</span>
</div>
<Button appearance="primary" size="small" className="mt-3">
Follow
</Button>
</Popover.Content>
</>
),
},
};Context Popover
export const ContextPopover: Story = {
args: {
openOnContext: true,
children: (
<>
<Popover.Trigger>
<div
role="group"
aria-label="Files"
aria-keyshortcuts="Shift+F10"
className="flex w-64 flex-col items-stretch gap-1"
>
{['Report.docx', 'Budget.xlsx', 'Slides.pptx'].map((file) => (
<Button key={file} appearance="subtle" className="justify-start">
{file}
</Button>
))}
<Input aria-label="Filter files" placeholder="Filter" />
</div>
</Popover.Trigger>
<Popover.Content title="File details">
<p style={{ margin: 0 }}>Shared with 3 people, edited today.</p>
<Button size="small" className="mt-3">
Share
</Button>
</Popover.Content>
</>
),
},
};Anchored To Target
export const AnchoredToTarget: Story = {
render: function AnchoredToTargetStory({ onOpenChange, ...args }) {
const [open, setOpen] = React.useState(false);
const [target, setTarget] = React.useState<HTMLButtonElement | null>(null);
const contentId = React.useId();
const change = (next: boolean) => {
setOpen(next);
onOpenChange?.(next);
};
return (
<>
<Button
ref={setTarget}
aria-haspopup="dialog"
aria-expanded={open}
aria-controls={open ? contentId : undefined}
onClick={() => change(!open)}
>
Details
</Button>
<Popover {...args} open={open} onOpenChange={change} target={target}>
<Popover.Content id={contentId} title="Details">
<p style={{ margin: 0 }}>Anchored to the Details button.</p>
<Button size="small" className="mt-3" onClick={() => change(false)}>
Close
</Button>
</Popover.Content>
</Popover>
</>
);
},
};Motion
export const Motion: Story = {
render: function MotionPopovers({ children: _children, ...args }) {
return (
<div className="flex flex-wrap gap-2">
{motionCases(fadeAndZoom).map(({ label, motion }) => (
// The story renders one popover per case; every other arg is forwarded.
<Popover key={label} {...args}>
<Popover.Trigger>
<Button>{label}</Button>
</Popover.Trigger>
<Popover.Content title={label} motion={motion}>
<p style={{ margin: 0 }}>Press Escape or click outside to see the exit.</p>
</Popover.Content>
</Popover>
))}
</div>
);
},
};Appearances And Sizes
export const AppearancesAndSizes: Story = {
render: function AppearancesAndSizesPopovers({ children: _children, ...args }) {
return (
<div className="flex flex-wrap gap-2">
{(['neutral', 'brand', 'inverted'] as const).map((appearance) => (
<Popover key={appearance} {...args} appearance={appearance}>
<Popover.Trigger>
<Button>{appearance}</Button>
</Popover.Trigger>
<Popover.Content title={`A ${appearance} popover`}>
<p style={{ margin: 0 }}>Content that reads on the {appearance} surface.</p>
</Popover.Content>
</Popover>
))}
{(['small', 'large'] as const).map((size) => (
<Popover key={size} {...args} size={size} withArrow={false}>
<Popover.Trigger>
<Button>{size}, no arrow</Button>
</Popover.Trigger>
<Popover.Content title={`A ${size} popover`}>
<p style={{ margin: 0 }}>Padded {size}.</p>
</Popover.Content>
</Popover>
))}
</div>
);
},
};Focus Trap And Role
export const FocusTrapAndRole: Story = {
render: function FocusTrapPopovers({ children: _children, ...args }) {
return (
<div className="flex flex-wrap gap-2">
<Popover {...args} trapFocus>
<Popover.Trigger>
<Button>Rename (focus trapped)</Button>
</Popover.Trigger>
<Popover.Content title="Rename">
<Input aria-label="New name" />
<Button size="small" className="mt-3">
Save
</Button>
</Popover.Content>
</Popover>
<Popover {...args}>
<Popover.Trigger>
<Button>Details (group)</Button>
</Popover.Trigger>
<Popover.Content title="Details" role="group">
<p style={{ margin: 0 }}>Created yesterday by Ada.</p>
</Popover.Content>
</Popover>
</div>
);
},
};Inline And Close On Scroll
export const InlineAndCloseOnScroll: Story = {
render: function InlinePopovers({ children: _children, ...args }) {
return (
<div className="flex flex-wrap items-start gap-4">
<div
className="relative rounded-md border border-wave-border p-4"
style={{ minHeight: 160 }}
>
<Popover {...args} inline>
<Popover.Trigger>
<Button>Inline popover</Button>
</Popover.Trigger>
<Popover.Content title="In place">
<p style={{ margin: 0 }}>Rendered inside the box.</p>
</Popover.Content>
</Popover>
</div>
<div className="h-24 w-64 overflow-auto rounded-md border border-wave-border p-2">
<Popover {...args} closeOnScroll>
<Popover.Trigger>
<Button>Closes on scroll</Button>
</Popover.Trigger>
<Popover.Content title="Scroll away">
<p style={{ margin: 0 }}>Scroll this box to close me.</p>
</Popover.Content>
</Popover>
<div style={{ height: 200 }} aria-hidden="true" />
</div>
</div>
);
},
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
open | boolean | No | Controlled open state of the popover. The content renders only in the browser: an open popover is closed in the server HTML and opens once it has hydrated. | |
defaultOpen | boolean | No | false | Default open state for uncontrolled usage. The content renders only in the browser: a popover open by default is closed in the server HTML and opens once it has hydrated. |
onOpenChange | (open: boolean, details?: PopoverOpenChangeDetails) => void | No | Called with the requested open state when it differs from the current one: a trigger click, Escape and an outside press; the hover opening and closing of The second argument says why ( | |
side | 'top' | 'bottom' | 'start' | 'end' | 'left' | 'right' | No | 'bottom' | Side of the trigger the content opens on. |
align | 'start' | 'center' | 'end' | No | 'start' | Alignment of the content along the trigger's edge. |
ignoreOutsideRefs | ReadonlyArray<React.RefObject<HTMLElement | null>> | No | Elements outside the popover whose presses must not dismiss it, e.g. an external toggle button that opens and closes the popover itself. | |
openOnHover | boolean | No | false | Open the popover when a mouse pointer rests on its trigger (a hover card), and close it once the pointer has been off the trigger and the content for |
openDelay | number | No | 250 | Milliseconds a hovering mouse pointer rests on the trigger before the popover opens (mouse hover only). |
closeDelay | number | No | 500 | Milliseconds before a hover-opened popover closes once the mouse pointer has left it and its trigger (Fluent's |
openOnContext | boolean | No | false | Make |
target | PopupTargetInput | No | Where to place the content instead of next to | |
positioning | PopupPositioning | No | `{ offset: 8 }` | Advanced positioning (Fluent's |
withArrow | boolean | No | true | Draws the beak, the small triangle that points at the trigger (or |
trapFocus | boolean | No | false | Traps focus in the content while it is open, like a dialog that leaves the page usable: focus moves into the content when it opens (its first focusable element, else the content itself) and Tab and Shift+Tab cycle inside it, toasts and popups opened from it included; Escape and a press outside still close it. A hover-opened popover ( |
inline | boolean | No | false | Renders the content in place, as the next sibling of the element that renders |
closeOnScroll | boolean | No | false | Closes the popover when anything outside it scrolls (the page, or any scrollable container; a scroll inside the content or inside a popup opened from it does not), reporting the reason |
appearance | 'neutral' | 'brand' | 'inverted' | No | 'neutral' | The look of the content: |
size | 'small' | 'medium' | 'large' | No | 'medium' | The padding of the content: |
children | React.ReactNode | Yes |
|
Parts
Popover.TriggerPopover.Content