# @salmonui/overlays/popover API reference

> 18 exported symbols of @salmonui/overlays/popover: 1 component, 5 functions, 7 interfaces and 5 types.

Canonical: https://salmonui.dev/docs/reference/overlays/popover

```ts
import { … } from '@salmonui/overlays/popover';
```

## Components

### PopoverContent

Kind: component

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverContent

```ts
function PopoverContent(props: PopoverContentProps): ReactNode;
```

The floating panel (`role="dialog"`, no `aria-modal`): mounted only while
open, in the top layer, positioned next to the trigger (or `anchor`).
Labelled by `Popover.Title` and described by `Popover.Description` when
they are rendered and no `aria-label` / `aria-labelledby` is given.

Props: [`PopoverContentProps`](https://salmonui.dev/docs/reference/overlays/popover/PopoverContentProps) (its members are the props)

## Functions

### Popover

Kind: function

Page: https://salmonui.dev/docs/reference/overlays/popover/Popover

```ts
function Popover(props: PopoverProps): ReactElement;

namespace Popover {
    export { PopoverTrigger as Trigger };
    export { PopoverContent as Content };
    export { PopoverTitle as Title };
    export { PopoverDescription as Description };
    export { PopoverClose as Close };
}
```

Popover root: holds the open triad and the ids. Renders no element of its
own.

### PopoverClose

Kind: function

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverClose

```ts
function PopoverClose(props: PopoverCloseProps): ReactElement;
```

A button that closes the popover (`reason: 'close'`); `render` swaps the element.

### PopoverDescription

Kind: function

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverDescription

```ts
function PopoverDescription(props: PopoverDescriptionProps): ReactElement;
```

Description of the popover (`<p>`); describes the content.

### PopoverTitle

Kind: function

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverTitle

```ts
function PopoverTitle(props: PopoverTitleProps): ReactElement;
```

Heading of the popover (`<h2>`); labels the content.

### PopoverTrigger

Kind: function

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverTrigger

```ts
function PopoverTrigger(props: PopoverTriggerProps): ReactElement;
```

The element that toggles the popover: a `<button type="button">` with
`aria-haspopup="dialog"`, `aria-expanded` and, while open,
`aria-controls`. `render` swaps the element (`render={(p) => <Button {...p} />}`).

## Interfaces

### PopoverCloseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverCloseProps

```ts
interface PopoverCloseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
    readonly render?: ((props: PopoverCloseRenderProps) => ReactElement) | undefined;
    readonly ref?: Ref<HTMLButtonElement> | undefined;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `render` | `readonly render?: ((props: PopoverCloseRenderProps) => ReactElement) \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLButtonElement> \| undefined;` | optional |  |

### PopoverContentProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverContentProps

```ts
interface PopoverContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'id'> {
    readonly children?: ReactNode;
    readonly ref?: Ref<HTMLDivElement> | undefined;
}
```

`id` is reserved: the trigger's `aria-controls` points at it.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `readonly children?: ReactNode;` | optional |  |
| `ref` | `readonly ref?: Ref<HTMLDivElement> \| undefined;` | optional | The content element (`role="dialog"`). |

### PopoverDescriptionProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverDescriptionProps

```ts
interface PopoverDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
    readonly ref?: Ref<HTMLParagraphElement> | undefined;
}
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `readonly ref?: Ref<HTMLParagraphElement> \| undefined;` | optional |  |

### PopoverOpenChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverOpenChangeEvent

```ts
interface PopoverOpenChangeEvent {
    readonly reason: PopoverOpenChangeReason;
    readonly source: PressSource | 'api';
}
```

Second argument of `onOpenChange`: frozen, allocated only when a callback is bound.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `reason` | `readonly reason: PopoverOpenChangeReason;` |  |  |
| `source` | `readonly source: PressSource \| 'api';` |  |  |

### PopoverProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverProps

```ts
interface PopoverProps {
    readonly children?: ReactNode;
    readonly open?: boolean | undefined;
    readonly defaultOpen?: boolean | undefined;
    readonly onOpenChange?: ((open: boolean, event: PopoverOpenChangeEvent) => void) | undefined;
    readonly placement?: PopoverPlacement | undefined;
    readonly offset?: PopoverOffset | undefined;
    readonly arrow?: boolean | undefined;
    readonly collisionBoundary?: Element | null | undefined;
    readonly anchor?: RefObject<Element | null> | undefined;
    readonly container?: Element | null | undefined;
    readonly closeOnOutsidePress?: boolean | undefined;
    readonly closeOnEscape?: boolean | undefined;
    readonly closeOnFocusOutside?: boolean | undefined;
    readonly initialFocus?: 'first' | 'container' | false | undefined;
    readonly returnFocus?: boolean | undefined;
}
```

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `readonly children?: ReactNode;` | optional | `Popover.Trigger` and `Popover.Content` (any order, any depth). |
| `open` | `readonly open?: boolean \| undefined;` | optional |  |
| `defaultOpen` | `readonly defaultOpen?: boolean \| undefined;` | optional | Applied after hydration, so server and client markup stay identical. |
| `onOpenChange` | `readonly onOpenChange?: ((open: boolean, event: PopoverOpenChangeEvent) => void) \| undefined;` | optional |  |
| `placement` | `readonly placement?: PopoverPlacement \| undefined;` | optional | Logical placement, resolved against `dir`. Default `'bottom'`. Flips and shifts to stay inside the collision boundary. |
| `offset` | `readonly offset?: PopoverOffset \| undefined;` | optional | Gap to the anchor in px (default 8), or `{ mainAxis, crossAxis }`. |
| `arrow` | `readonly arrow?: boolean \| undefined;` | optional | Renders an arrow pointing at the anchor. Default false. |
| `collisionBoundary` | `readonly collisionBoundary?: Element \| null \| undefined;` | optional | Element whose box limits flip and shift (a scrolling container). Default the viewport. |
| `anchor` | `readonly anchor?: RefObject<Element \| null> \| undefined;` | optional | Anchor element other than the trigger (a field the popover belongs to). |
| `container` | `readonly container?: Element \| null \| undefined;` | optional | Portal target for browsers without the Popover API (top layer otherwise). Default `document.body`. |
| `closeOnOutsidePress` | `readonly closeOnOutsidePress?: boolean \| undefined;` | optional | Close on a press outside the content and trigger. Default true. |
| `closeOnEscape` | `readonly closeOnEscape?: boolean \| undefined;` | optional | Close on Escape. Default true. |
| `closeOnFocusOutside` | `readonly closeOnFocusOutside?: boolean \| undefined;` | optional | Close when focus moves outside (Tab past the last control). Default true. |
| `initialFocus` | `readonly initialFocus?: 'first' \| 'container' \| false \| undefined;` | optional | Initial focus: the first tabbable control (default), the content element, or none. |
| `returnFocus` | `readonly returnFocus?: boolean \| undefined;` | optional | Return focus to the trigger on close. Default true. |

### PopoverTitleProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverTitleProps

```ts
interface PopoverTitleProps extends HTMLAttributes<HTMLHeadingElement> {
    readonly ref?: Ref<HTMLHeadingElement> | undefined;
}
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `readonly ref?: Ref<HTMLHeadingElement> \| undefined;` | optional |  |

### PopoverTriggerProps

Kind: interface

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverTriggerProps

```ts
interface PopoverTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
    readonly render?: ((props: PopoverTriggerRenderProps) => ReactElement) | undefined;
    readonly ref?: Ref<HTMLButtonElement> | undefined;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `render` | `readonly render?: ((props: PopoverTriggerRenderProps) => ReactElement) \| undefined;` | optional | Renders another element (a `Button`, a link) with the computed props. |
| `ref` | `readonly ref?: Ref<HTMLButtonElement> \| undefined;` | optional |  |

## Types

### PopoverCloseRenderProps

Kind: type

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverCloseRenderProps

```ts
type PopoverCloseRenderProps = PopoverTriggerRenderProps;
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `ref: Ref<HTMLButtonElement>;` | inherited |  |

### PopoverOffset

Kind: type

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverOffset

```ts
type PopoverOffset = OverlayOffset;
```

### PopoverOpenChangeReason

Kind: type

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverOpenChangeReason

```ts
type PopoverOpenChangeReason = 'trigger' | 'close' | 'escape' | 'outside' | 'focus-outside' | 'api';
```

### PopoverPlacement

Kind: type

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverPlacement

```ts
type PopoverPlacement = OverlayPlacement;
```

### PopoverTriggerRenderProps

Kind: type

Page: https://salmonui.dev/docs/reference/overlays/popover/PopoverTriggerRenderProps

```ts
type PopoverTriggerRenderProps = ButtonHTMLAttributes<HTMLButtonElement> & {
    readonly ref: Ref<HTMLButtonElement>;
};
```

Props `Popover.Trigger` computes for its element (spread them in `render`).

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `ref: Ref<HTMLButtonElement>;` | inherited |  |
