# Popover

> An anchored panel that opens next to a trigger and holds interactive content — quick settings, a small form, more than a tooltip can carry.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Overlays
- Tags: overlay, popover, anchored, disclosure, accessibility
- Types: `PopoverProps`, `PopoverContentProps`, `PopoverContext`
- Docs: https://fancy-ui.rama.app/docs/components/popover
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/popover

## Import

```tsx
import { Popover } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | `false` | Whether the panel is open. Bindable |
| `onOpenChange` | `(open: boolean) => void` | — | Called with the new value whenever the panel opens or closes, however the change happened |
| `side` | `"top" \| "bottom" \| "left" \| "right"` | `"bottom"` | Side of the trigger to place the panel on. Flips when it would overflow |
| `align` | `"start" \| "center" \| "end"` | `"center"` | Alignment along the trigger's cross axis |
| `offset` | `number` | `8` | Gap in pixels between the trigger and the panel |
| `dismissible` | `boolean` | `true` | Whether Escape and an outside click close the panel |
| `className` (Svelte `class`) | `string` | — | Additional CSS classes, merged onto the panel |
| `ref` | `HTMLDivElement \| null` | `null` | Bindable reference to the panel element |
| `sound` | `boolean` | `false` | Plays open when the trigger opens the panel and close on a dismissal, once the user has enabled sound |

## Node props

| Prop | Description |
| --- | --- |
| `trigger` | The trigger's content, rendered inside the real <button> this component owns and wires up |
| `children` | The panel's content |

## Example

```tsx
import { useState } from "react";
import { Popover } from "fancy-ui-react";

export function PopoverExample() {
	const [width, setWidth] = useState("100%");
	const [height, setHeight] = useState("25px");

	return (
		<Popover sound className="w-[220px]" trigger="⚙ Options">
			<span className="text-[13px] font-semibold">Dimensions</span>
			<div className="flex gap-2">
				<input
					value={width}
					onChange={(event) => setWidth(event.target.value)}
					aria-label="Width"
					className="border-input bg-background text-foreground min-w-0 flex-1 rounded-[6px] border px-2 py-[5px] text-[12px]"
				/>
				<input
					value={height}
					onChange={(event) => setHeight(event.target.value)}
					aria-label="Height"
					className="border-input bg-background text-foreground min-w-0 flex-1 rounded-[6px] border px-2 py-[5px] text-[12px]"
				/>
			</div>
		</Popover>
	);
}
```
