Popover
Rich content in a floating panel, opened by click.
Left out of Accessible first Optional help here sits in a section a person can open, in the page. One clear way to do each thing leaves no room for a floating panel too. Use instead: Collapsible
See it live
npm run storybookWhen to use it
- Use it when: Extra detail or a small control next to what it explains, on any device.
- Not when: A one-line hint (tooltip), or a task that should block the page (dialog).
Instead:
Words
- Use common words. Explain any term you must use.
- One idea per sentence. Put the action first.
- Never blame the person.
- Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.
The labels components use, from the voice tokens:
content.action.commit: Continuecontent.action.cancel: Go backcontent.action.destroy: Deletecontent.action.retry: Try againcontent.action.empty-action: Start a new application
See Voice and tone for the whole voice.
Accessibility and keyboard
| Keyboard | What happens | Not |
|---|---|---|
| undefined | Escape closes it and returns focus. | undefined |
Test before you ship:
- The trigger says it opens a panel and whether it is open. undefined
Use it in code
npx open-ds add popover
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Popover reads 10 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Popover's tokens to change Popover alone.
Accessible first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Shared | ||
| Transition panels duration | component.transition.panels-durationmotion.duration.panelsvar(--transition-panels-duration) | duration.moderate:200ms |
| Content | ||
| Corner | component.popover.content.radiusradius.controlvar(--popover-content-radius) | radius.6:0.375rem |
| Fill Changes with theme | component.popover.content.backgroundcolor.surface.raisedvar(--popover-content-background) | Lightgray.light.0:#FFFFFFDarkgray.dark.100:#222222 |
| Padding | component.popover.content.paddingspace.inset.containervar(--popover-content-padding) | space.24:1.5rem |
| Text Changes with theme | component.popover.content.labelcolor.text.primaryvar(--popover-content-label) | Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7 |
| Shadow | component.popover.content.shadowelevation.overlayvar(--popover-content-shadow) | shadow.none |
| Header | ||
| Gap | component.popover.header.gapspace.gap.tightvar(--popover-header-gap) | space.12:0.75rem |
| Text size | component.popover.header.font-sizetype.body.font-sizevar(--popover-header-font-size) | font.size.19:1.1875rem |
| Title | ||
| Weight | component.popover.title.font-weighttype.label.font-weightvar(--popover-title-font-weight) | font.weight.700:700 |
| Description | ||
| Text Changes with theme | component.popover.description.labelcolor.text.mutedvar(--popover-description-label) | Lightgray.light.500:#595959Darkgray.dark.500:#949494 |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightgray.light.200 · #D6D6D6Darkgray.dark.100 · #222222 |