Popover
A floating panel anchored to a trigger element for displaying rich content.
Import
import { Popover } from '@matix/components/popover';Usage
With Arrow
Set arrow on Popover.Popup to render a pointer arrow toward the trigger.
With Form Content
Popovers can contain interactive form elements. By default, Popover.Close is an icon button in the top-right corner. To close from your own button, pass it as render, and Popover.Close drops its corner styles.
Placement
Control positioning via the side and align props on Popover.Positioner.
Custom Styles
Use the sx prop on any sub-component to override styles.
import * as stylex from '@stylexjs/stylex';
const custom = stylex.create({
popup: { maxWidth: '320px', borderRadius: '16px' },
title: { fontWeight: 700 },
});
<Popover.Root>
<Popover.Trigger>Styled Popover</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner>
<Popover.Popup sx={custom.popup}>
<Popover.Title sx={custom.title}>Custom Styled</Popover.Title>
<Popover.Description>This popover uses custom StyleX overrides.</Popover.Description>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>;Server Components
Popover is a client component. A Server Component cannot read a property of a client component, so Popover.Root is undefined there. In a Server Component, import the named parts. Each Popover.<Part> is also exported as Popover<Part>.
import {
PopoverRoot,
PopoverTrigger,
PopoverPortal,
PopoverPositioner,
PopoverPopup,
PopoverTitle,
PopoverDescription,
PopoverClose,
} from '@matix/components/popover';In a client component, both forms work.
API Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Popover.Root | open | boolean | — | Controlled open state |
Popover.Root | onOpenChange | (open: boolean) => void | — | Called when the open state changes |
Popover.Trigger | sx | StyleXStyles | — | StyleX style override |
Popover.Portal | container | HTMLElement | document.body | Portal target |
Popover.Positioner | side | 'top' | 'right' | 'bottom' | 'left' | 'bottom' | Preferred side |
Popover.Positioner | align | 'start' | 'center' | 'end' | 'center' | Alignment along the side |
Popover.Popup | arrow | boolean | false | Show arrow pointer toward the trigger |
Popover.Popup | sx | StyleXStyles | — | StyleX style override |
Popover.Title | sx | StyleXStyles | — | StyleX style override |
Popover.Description | sx | StyleXStyles | — | StyleX style override |
Popover.Close | sx | StyleXStyles | — | StyleX style override |
All sub-components forward additional props to their underlying Base UI elements.
Accessibility
- Built on Base UI
Popover-- full WAI-ARIA popover pattern. - Focus moves into the popup when opened and returns to the trigger on close.
Popover.Titlemaps toaria-labelledbyandPopover.Descriptiontoaria-describedbyon the popup.- The popover is dismissed on outside click or
Escape.
Keyboard
| Key | Action |
|---|---|
Escape | Closes the popover |
Tab | Moves focus to the next focusable element inside the popover |
Shift + Tab | Moves focus to the previous focusable element inside the popover |