Popover
Web/MobileDisplays rich content in a portal, triggered by a button.
Installation
pnpm dlx cubix-ui@latest add popover --base ariaUsage
import { Button } from "@/components/cubix/button"
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverHeader,
PopoverTitle,
PopoverTrigger,
} from "@/components/cubix/popover"
<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.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled open state. Omit to use uncontrolled mode. |
| defaultOpen | boolean | false | Initial 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. |
| children | React.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.
| Prop | Type | Default | Description |
|---|---|---|---|
| render | React.ReactElement | - | Render the trigger or close control as another Cubix element (e.g. a Button). |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
PopoverContent
The panel rendered in a portal, positioned relative to the trigger.
| Prop | Type | Default | Description |
|---|---|---|---|
| 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). |
| sideOffset | number | 4 | Distance in pixels between the trigger and the popover. |
| alignOffset | number | 0 | Offset in pixels along the alignment axis. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes are forwarded to the popover panel. |
PopoverHeader / PopoverTitle / PopoverDescription
Optional layout and text helpers for the popover panel.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |