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

ComponentPropTypeDefaultDescription
Popover.Rootopenboolean—Controlled open state
Popover.RootonOpenChange(open: boolean) => void—Called when the open state changes
Popover.TriggersxStyleXStyles—StyleX style override
Popover.PortalcontainerHTMLElementdocument.bodyPortal target
Popover.Positionerside'top' | 'right' | 'bottom' | 'left''bottom'Preferred side
Popover.Positioneralign'start' | 'center' | 'end''center'Alignment along the side
Popover.PopuparrowbooleanfalseShow arrow pointer toward the trigger
Popover.PopupsxStyleXStyles—StyleX style override
Popover.TitlesxStyleXStyles—StyleX style override
Popover.DescriptionsxStyleXStyles—StyleX style override
Popover.ClosesxStyleXStyles—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.Title maps to aria-labelledby and Popover.Description to aria-describedby on the popup.
  • The popover is dismissed on outside click or Escape.

Keyboard

KeyAction
EscapeCloses the popover
TabMoves focus to the next focusable element inside the popover
Shift + TabMoves focus to the previous focusable element inside the popover