Popover

Displays rich content in a portal, triggered by a button.

Installation

pnpm dlx cubix@latest add popover --base aria

Usage

Import
import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/components/cubix/popover"
Example
<Popover>
  <PopoverTrigger render={<Button variant="outline" />}>
Open popover
</PopoverTrigger>
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle>Dimensions</PopoverTitle>
      <PopoverDescription>
        Set the dimensions for the layer.
      </PopoverDescription>
    </PopoverHeader>
  </PopoverContent>
</Popover>

Examples

Sides

Use side to place the popover relative to the trigger.

Align

Use align to shift the panel along the opposite axis.

With form

Popovers can hold interactive content such as inputs and actions.

API Reference

Note: The popover is not modal. Escape and clicking outside close it, and focus returns to the trigger. Use Dialog when you need a focus-trapped overlay.

Popover

The container that wraps the trigger and content and manages open state.

PropTypeDefaultDescription
openboolean-Controlled open state. Omit to use uncontrolled mode.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void-Called when the open state changes.
childrenReact.ReactNode-The trigger and content elements.

PopoverTrigger

The element that opens the popover. Use render to merge onto a Button.

PropTypeDefaultDescription
renderReact.ReactElement-Render the trigger as another element (e.g. a Button).
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

PopoverContent

The panel rendered in a portal next to the trigger.

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""bottom"Preferred side of the trigger to render the popover on.
align"start" | "center" | "end""center"Alignment along the opposite axis of `side`.
sideOffsetnumber8Distance in pixels between the trigger and the popover.
alignOffsetnumber0Offset in pixels along the alignment axis.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
...propsReact.ComponentProps<'div'>-All native div attributes are forwarded to the popover panel.

PopoverHeader / PopoverTitle / PopoverDescription

Optional layout and text helpers for the popover panel.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).