Components
Popover
Popover appears above other elements in the interface and is linked to a specific element. It is used to display additional information, interactive elements, or brief explanations without navigating away from the page.
<button
class="ds-button"
type="button"
popoverTarget="popover-preview-en"
>Open popover</button>
<div
class="ds-popover"
id="popover-preview-en"
popover="manual"
data-placement="top"
>
The popover provides a quick message. You can use it to show the user
information that is relevant to the context.
</div>const PreviewEn = () => { return ( <> <Button popovertarget='popover-preview-en'>Open popover</Button> <Popover id='popover-preview-en' placement='top'> The popover provides a quick message. You can use it to show the user information that is relevant to the context. </Popover> </> ); }; render(<PreviewEn />)
Use popover when
- you need to provide additional explanations that require more space than a short tooltip, such as definitions or detailed instructions
- context-specific help is needed that users can open and close without leaving the page
- supplementary information should be shown that is not critical for completing the task, but may be useful for some users
Avoid popover when
- you need to describe a symbol or keyboard shortcut; use tooltip instead
- the purpose is navigation or choosing between options; use dropdown instead
- the content is intended to appear on hover
Example
Interactive popover
Popover may contain buttons and other interactive elements.
<button
class="ds-button"
type="button"
popoverTarget="popover-interactive-en"
data-color="danger"
aria-label="Delete row"
>
<svg aria-labelledby="title-_R_9_" role="img"></svg>
</button>
<div
class="ds-popover"
id="popover-interactive-en"
popover="manual"
data-placement="top"
data-color="danger"
>
<p class="ds-paragraph">
Are you sure you want to delete this row? This action cannot be
undone.
</p>
<div
style="display:flex;gap:var(--ds-size-2);margin-top:var(--ds-size-2)"
>
<button class="ds-button" type="button" data-size="sm">Yes, delete it</button>
<button
class="ds-button"
data-variant="tertiary"
type="button"
data-size="sm"
>Cancel</button>
</div>
</div>const InteractiveEn = () => { return ( <> <Button data-color='danger' aria-label='Delete row' popovertarget='popover-interactive-en' > <TrashIcon title='Delete row' /> </Button> <Popover id='popover-interactive-en' data-color='danger'> <Paragraph> Are you sure you want to delete this row? This action cannot be undone. </Paragraph> <div style={{ display: 'flex', gap: 'var(--ds-size-2)', marginTop: 'var(--ds-size-2)', }} > <Button data-size='sm'>Yes, delete it</Button> <Button data-size='sm' variant='tertiary'> Cancel </Button> </div> </Popover> </> ); }; render(<InteractiveEn />)
Inline trigger
You can use popover inline within text, marked with a dotted underline, for example when explaining a term.
<p class="ds-paragraph">
We use
<!-- -->
<button
type="button"
data-popover="inline"
popovertarget="popover-dotted-underline-en"
>design tokens</button>
<!-- -->
to ensure a consistent design.
</p>
<div
class="ds-popover"
id="popover-dotted-underline-en"
popover="manual"
data-placement="top"
data-color="neutral"
>
<p class="ds-paragraph">
<strong style="display:block">Design tokens</strong>
Design tokens are a collection of variables that define the visual
style within a design system.
</p>
</div>const DottedUnderlineEn = () => { return ( <> <Paragraph> We use{' '} <button type='button' data-popover='inline' popovertarget='popover-dotted-underline-en' > design tokens </button>{' '} to ensure a consistent design. </Paragraph> <Popover id='popover-dotted-underline-en' data-color='neutral'> <Paragraph> <strong style={{ display: 'block', }} > Design tokens </strong> Design tokens are a collection of variables that define the visual style within a design system. </Paragraph> </Popover> </> ); }; render(<DottedUnderlineEn />)
Guidelines
Popover is used to display more detailed or interactive supplementary information without taking the user out of context. It can be used as an extended solution when a tooltip is not sufficient. Popover is opened through an intentional user click and may contain text, links and simple form elements. The content should be short, relevant, and not critical for completing the task.
Placement
Popover can be placed as needed, and will automatically stay within the visible browser area. This behaviour can be disabled using autoPlacement.
Text
Avoid long texts and complex explanations. In some cases, it may be better to link to another page with more detailed information on the topic.
Edit this page on github.com (opens in a new tab)