Popover

Web/Mobile

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

Installation

pnpm dlx cubix-ui@latest add popover

Usage

Import
import { Button } from "@/components/cubix/button"
import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/cubix/popover"
Example
<Popover>
  <PopoverTrigger render={<Button variant="outline" size="sm" />}>
    باز کردن پاپ‌آور
  </PopoverTrigger>
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle>ابعاد</PopoverTitle>
      <PopoverDescription>ابعاد این لایه را تنظیم کنید.</PopoverDescription>
    </PopoverHeader>
  </PopoverContent>
</Popover>

Examples

Sides

Use side to place the popover relative to the trigger.

Align

Use align for logical alignment (ابتدا / انتها in RTL).

With form

Popovers can hold interactive Cubix fields and actions. Opening keeps focus on the trigger; Tab moves into the panel.

Close

Use PopoverClose with a Cubix Button to dismiss from inside the panel.

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.
dir"ltr" | "rtl""rtl"Text direction for the popover. Defaults to RTL. When omitted, follows the closest dir on the page.
childrenReact.ReactNode-The trigger and content elements.

PopoverTrigger / PopoverClose

The trigger toggles the popover. PopoverClose closes it from inside the panel. Compose both with Cubix Button via render.

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

PopoverContent

The panel rendered in a portal, positioned relative 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"Logical alignment along the opposite axis of side (ابتدا / انتها in RTL).
sideOffsetnumber4Distance 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).