Overlays
Popover
A small anchored surface for context.
Usage
Compose Popover, PopoverTrigger and PopoverContent. The content floats in the browser top layer next to the trigger, so an overflow: hidden parent never clips it. It is non-modal: the page stays usable and Esc or a click outside closes it.
When to use
- Small contextual content or a short form that belongs to one control.
- Anything that should not block the page.
Not for: a decision that must be finished first (use a dialog), a list of actions (use a dropdown menu), or a one-line hint (use a tooltip).
Forms and closing
Focus moves to the first field when it opens. PopoverClose closes it from inside; focus goes back to the trigger.
Placement and arrow
placement picks the side (and -start / -end alignment); it flips when there is no room. Add arrow to point at the trigger. matchWidth makes the panel at least as wide as the trigger.
API
Popover
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | — | Controlled open state. |
| defaultOpen | boolean | false | Initial state when uncontrolled. |
| onOpenChange | (open: boolean) => void | — | Called when the popover asks to open or close. |
PopoverContent
| Prop | Type | Default | Description |
|---|---|---|---|
| placement | 'top' | 'right' | 'bottom' | 'left' (+ '-start' | '-end') | 'bottom' | Preferred side and alignment. |
| align | 'start' | 'center' | 'end' | — | Overrides the alignment of placement. |
| offset | number | 6 (10 with arrow) | Gap to the trigger, px. |
| matchWidth | boolean | false | At least as wide as the trigger. |
| arrow | boolean | false | Show an arrow pointing at the trigger. |
| dismissible | boolean | true | Close on Esc, an outside click, or Tab leaving. |
PopoverTrigger and PopoverClose are buttons; pass asChild to use your own. Give the content an aria-label if the trigger’s text is not a good name for it.
Keyboard
| Key | Action |
|---|---|
| Enter / Space | On the trigger: toggles the popover. |
| Tab | Moves through the content; leaving it closes the popover. |
| Esc | Closes the popover and returns focus to the trigger. |
Accessibility
- Non-modal dialog: the trigger has aria-haspopup="dialog", aria-expanded and aria-controls; the content is role="dialog".
- Focus moves into the content on open and returns to the trigger on close (also in Safari and Firefox, which do not focus buttons on click).
- After an outside click focus stays where the person clicked.
Motion
- Open: pops from the trigger side, scale .96, 4px travel, light blur (220ms, ease-out).
- Close: 160ms fade; unmounts after the animation ends.
- Reduced motion: it appears and disappears without movement.