Popover
A popover anchored to a trigger element. Placement and arrow display are customizable.
View in Storybook (opens in a new tab)
Installation
import { Popover } from "@ginga-ui/core";Basic usage
A simple popover shown below its trigger. Supports focus management and keyboard interaction.
popover.tsx
import { Button, Popover, PopoverTrigger } from "@ginga-ui/core";
import { Info } from "lucide-react";
export function BasicExample() {
return (
<PopoverTrigger>
<Button variant="filled" startIcon={<Info />}>
Show details
</Button>
<Popover>
<p>This is the popover content.</p>
</Popover>
</PopoverTrigger>
);
}Placement
Use the placement prop to set the position, such as top, bottom, left, or right.
popover.tsx
popover.module.css
import { Button, Popover, PopoverTrigger } from "@ginga-ui/core";
import styles from "./popover.module.css";
export function PlacementsExample() {
return (
<div className={styles.placementList}>
{(["top", "bottom", "left", "right"] as const).map((placement) => (
<PopoverTrigger key={placement}>
<Button variant="outline">{placement}</Button>
<Popover placement={placement}>
<p>Appears on the {placement}.</p>
</Popover>
</PopoverTrigger>
))}
</div>
);
}Without arrow
Pass false to the showArrow prop to hide the arrow.
popover.tsx
import { Button, Popover, PopoverTrigger } from "@ginga-ui/core";
export function WithoutArrowExample() {
return (
<PopoverTrigger>
<Button variant="light">No arrow</Button>
<Popover showArrow={false}>
<p>A popover without an arrow.</p>
</Popover>
</PopoverTrigger>
);
}Props
PopoverTrigger
Accepts the props of React Aria's DialogTrigger (opens in a new tab).
Popover
| Name | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Content of the popover. It is wrapped in a dialog. |
showArrow | boolean | true | Shows an arrow pointing at the trigger. The offset grows by half the arrow size. |
placement | Placement | "bottom" | Position of the popover relative to the trigger. |
offset | number | 8 | Distance from the trigger in pixels. |
Also accepts the props of React Aria's Popover (opens in a new tab).