Popover
Shows content in a panel anchored to its trigger.
popover-demo.tsx
Installation
The CLI adds the files, packages, theme variables, and Tailwind plugin that this component uses. Before you run it, set up your project.
npm
yarn
pnpm
bun
Composition
PopoverTriggerOwns the open state.
ButtonPopoverPopoverArrowOptionalPopoverDialogPopoverTitlePopoverDescriptionOptionalPopoverFooterOptionalButtonSet slot="close" to close the popover.
Placement and arrow
Add start or end to align an edge, such as "bottom start". PopoverArrow follows the side.
popover-placement-demo.tsx
Form
Call close from the PopoverDialog render function after the form submits. Also install Text area.
popover-form-demo.tsx
Hover preview
Use PreviewTrigger from react-aria-components with a plain Popover, so hover does not move focus. Also install Avatar and Link.
Review requested by @mayachen for the pricing page redesign.
popover-preview-demo.tsx
API reference
vip/ui adds or changes the props below. For all other props, see React Aria Popover (opens in a new tab).
Popover
- className: string | ((values) => string)
- Set a width here, for example w-72. Without a width, the panel grows with its content, up to the viewport width minus 2rem. Use w-(--trigger-width) to match the trigger.
- maxHeight: number
- Caps the panel height. The panel always fits the viewport and scrolls when its content is taller. With PopoverArrow, the content scrolls inside the panel padding.
- arrowBoundaryOffset: number = 16
- The minimum distance from the arrow to the panel edge. It keeps the arrow off the rounded corner.
- data-placement: "top" | "bottom" | "left" | "right"
- Set on the panel. The side of the trigger that the panel opened on. The panel scales from --trigger-anchor-point.
- data-trigger: string
- Set on the panel. The name of the component that opened it, for example DialogTrigger or PreviewTrigger.
PopoverDialog
- children: ReactNode | ({ close }) => ReactNode
- Moves focus into the panel and keeps it there. Name it with PopoverTitle or aria-label. Use the function form to close after an action. A Button with slot="close" inside it closes the popover.