# Popover

Non-modal floating panel anchored to a trigger, built on Radix Popover. Uses the shared `popupSurface` style with no arrow.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| Popover.open / defaultOpen | boolean | — | Controlled or uncontrolled open state on the Popover root. |
| PopoverContent.sideOffset | number | 8 | Distance in pixels between trigger and popover panel. |
| PopoverContent.align | "start" \| "center" \| "end" | "center" | Alignment of the popover relative to its trigger. |
| PopoverContent.container | HTMLElement \| null | modal or body | Optional portal container override; defaults to nearest Dialog/Sheet portal container. |

## Sizes and tokens

| Tier / Role | Token | Value |
| --- | --- | --- |
| Width & padding | w-[min(18rem,calc(100vw-2rem))] / --space-4 | 288px width · 16px padding · 8px sideOffset · no arrow |
| Surface | --popover / --popover-foreground / --shadow-md / --z-dropdown | Step 3 surface · 1px border · radius-md (8px) · z-index 20 |
| Motion | --duration-162 / --duration-100 | Fade + scale 0.96→1 (162ms enter, 100ms exit); opacity-only when reduced |

## Code

```tsx
import {
  Button,
  Popover,
  PopoverClose,
  PopoverContent,
  PopoverTrigger,
} from "@freshgemui/monoplinth";

export function Example() {
  return (
    <Popover>
      <PopoverTrigger asChild>
        <Button variant="outline">Details</Button>
      </PopoverTrigger>
      <PopoverContent>
        <p>Token values update immediately on mode change.</p>
        <PopoverClose asChild>
          <Button size="sm" variant="secondary">
            Done
          </Button>
        </PopoverClose>
      </PopoverContent>
    </Popover>
  );
}
```

## Do and don't

- **Do: Use Popover for interactive secondary controls** — Place compact forms, filters, or rich details inside PopoverContent where keyboard users can tab through controls.
- **Don't: Use Popover for plain single-line hints** — Use Tooltip for short non-interactive text labels on hover and focus.

## Accessibility

- Focus moves into `PopoverContent` on open and returns to `PopoverTrigger` when closed via `Escape`, outside click, or `PopoverClose`.
- Inside `Dialog` or `Sheet`, `PopoverContent` automatically portals into the modal's container so it remains interactive above `z-modal`.

## Rationale

Sharing `popupSurface` with `Select` and `Tooltip` keeps all floating surfaces visually consistent while `sideOffset={8}` maintains clear breathing room from the trigger.
