Popover
Rich content anchored to a trigger, such as help text or a small form.
When to use
- Short help or detail anchored to a control: what an API key scope allows, who can see a record.
- A small form of one or two fields that belongs to its trigger: rename a workspace, pick a date.
When not to use
- A one-line label for an icon button: use Tooltip.
- A list of actions: use Dropdown Menu.
- A task with several fields and a footer: use Dialog.
- A preview of a linked record on hover: use Hover Card.
Install
npx shadcn@latest add @clinia/popoverAnatomy
Share this view
Anyone in the workspace with the link can open it.
- 1Trigger
data-slot="popover-trigger"Button - 2Popover
data-slot="popover-content"bg-popover · w-72 · p-4 - 3Title
data-slot="popover-title"text-base · font-medium - 4Description
data-slot="popover-description"text-muted-foreground
Clinia rules
- It is
w-72withp-4by default. Widen it withclassNamerather than cramming content in. - For a titled popover, use
PopoverHeaderwithPopoverTitle(text-base font-medium) andPopoverDescription(text-muted-foreground). - Keep it to one idea. If it needs to scroll, it belongs in a Sheet or a Dialog.
Do and don't
Share this view
Anyone in the workspace with the link can open it.
Edit source
Accessibility
Built in
- Opens on click, Enter or Space. Escape or a click outside closes it, and focus returns to the trigger.
PopoverTitleandPopoverDescriptionname and describe the popup for screen readers.
Your responsibility
- Give an icon-only trigger an
aria-labelthat says what it opens:About API key scopes. - Render a
PopoverTitlein any popover with a form, so the popup has a name.
How to test
- Press Tab to the trigger, then Enter: the popover opens.
- Press Tab: focus moves through the popover's content.
- Press Escape: it closes and focus returns to the trigger.
- With a screen reader, the trigger announces its label, and opening it reads the popover's title.
API
PopoverContent
| Prop | Values | Default | Description |
|---|---|---|---|
| align | centerstartend | center | Edge of the trigger the popover lines up with. |
| alignOffset | number | OffsetFunction | 0 | Shift along the aligned edge, in pixels. |
| side | topbottomleftrightinline-endinline-start | bottom | Side of the trigger the popover opens on. |
| sideOffset | number | OffsetFunction | 4 | Gap between the trigger and the popover, in pixels. |
All other props come from Base UI Popover.