# Popover

A small panel that opens from a button and can hold controls.

- **Use it for**: Interactive content anchored to a trigger, such as a small form or filter.
- **Not for**: Short descriptions without controls, or focused tasks. Try [Tooltip](https://unseenui.com/components/tooltip/), [Modal](https://unseenui.com/components/modal/).

## Installation

```bash
npm install @stackunseen/ui
```

## Parts

A small panel that opens from a button and can hold controls. Focus and closing on Escape or outside clicks are handled for you.

```tsx
<Popover open={open} onOpenChange={setOpen}>
  <Popover.Trigger asChild>
    <Button variant="outline">Project details</Button>
  </Popover.Trigger>
  <Popover.Content title="Project details">
    {/* fields */}
    <Popover.Close asChild>
      <Button>Done</Button>
    </Popover.Close>
  </Popover.Content>
</Popover>
```

1. **`Popover`**: Holds the open state; leave it uncontrolled or pass `open` and `onOpenChange`.
2. **`Popover.Trigger`**: Opens it. Pass your own Button with `asChild`. Props: `variant`, `size`.
3. **`Popover.Content`**: The panel; `title` is its heading. Props: `title`, `description`, `headingLevel`, `container`.
4. **`Popover.Close`**: A button that closes it, such as Done.
5. **`Popover.Arrow`**: An optional pointer toward the trigger.

## Usage

```tsx
import { Popover } from '@stackunseen/ui';
import { Button, Field, Input } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<Popover open={open} onOpenChange={setOpen}><Popover.Trigger asChild><Button variant="outline">Project details</Button></Popover.Trigger><Popover.Content title="Project details"><Field label="Project name"><Input value={name} onChange={event => setName(event.target.value)} /></Field><Popover.Close asChild><Button>Done</Button></Popover.Close></Popover.Content></Popover>
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `dir` | `"ltr" \| "rtl"` | Set for locally scoped RTL layouts so the portal and trigger share direction. |

## Keyboard

Enter or Space opens the trigger. Focus moves into the panel; Escape closes it and returns focus.

## Works with

[Tooltip](https://unseenui.com/components/tooltip/), [ShortcutHelp](https://unseenui.com/components/shortcut-help/), [AlertDialog](https://unseenui.com/components/alert-dialog/), [Modal](https://unseenui.com/components/modal/)

Page: https://unseenui.com/components/popover/
