Skip to content

Alert dialog

BetaFeedback and overlaysOpen in the workshop

Confirms a destructive or costly action, and says what will happen.

dialog.xg-modal.xg-modal--sm[role=alertdialog] with .xg-alert-dialog__icon and a danger primary

Example and markup

Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.

Alert dialog

Delete Holiday promo — CTV?

The campaign stops buying at once and its 12 creatives are removed. Reports keep its history.

Markup
<button class="xg-btn xg-btn--danger" type="button" data-xg-open="dlg-del">
<svg class="xg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M4 7h16"/>
<path d="M10 11v6"/>
<path d="M14 11v6"/>
<path d="M6 7l1 13h10l1-13"/>
<path d="M9 7V4h6v3"/>
</svg>Delete campaign</button>
<dialog class="xg-modal xg-modal--sm" id="dlg-del" role="alertdialog" aria-labelledby="dlg-del-t" aria-describedby="dlg-del-d">
<form method="dialog" style="display:contents">
<div class="xg-modal__header">
<span class="xg-alert-dialog__icon" aria-hidden="true">!</span>
<h2 class="xg-modal__title" id="dlg-del-t">Delete Holiday promo — CTV?</h2>
</div>
<div class="xg-modal__body">
<p id="dlg-del-d">The campaign stops buying at once and its 12 creatives are removed. Reports keep its history.</p>
</div>
<div class="xg-modal__footer">
<button class="xg-btn xg-btn--secondary" value="cancel" autofocus>Cancel</button>
<button class="xg-btn xg-btn--danger" value="delete">Delete campaign</button>
</div>
</form>
</dialog>

Variants

Static render

Block Partner 3?

Partner 3 stops receiving requests from all 4 of your placements. You can unblock it later.

Markup
<div class="xg-modal xg-modal--static xg-modal--sm" role="alertdialog" aria-labelledby="sad-t">
<div class="xg-modal__header">
<span class="xg-alert-dialog__icon" aria-hidden="true">!</span>
<h2 class="xg-modal__title" id="sad-t">Block Partner 3?</h2>
</div>
<div class="xg-modal__body">
<p>Partner 3 stops receiving requests from all 4 of your placements. You can unblock it later.</p>
</div>
<div class="xg-modal__footer">
<button class="xg-btn xg-btn--secondary" type="button">Cancel</button>
<button class="xg-btn xg-btn--danger" type="button">Block partner</button>
</div>
</div>

When to use it

Use it for

delete, block a partner, stop a live campaign, revoke an API key.

Not for

routine confirmations (“Are you sure you want to save?”): use Undo in a toast instead.

Rules

  • Title is a question with the object: “Delete Holiday promo — CTV?”.
  • Body says the consequence in one or two sentences, with numbers if any.
  • The danger button repeats the verb (“Delete campaign”); Cancel gets initial focus.

Accessibility

  • role="alertdialog", aria-describedby on the consequence text, initial focus on Cancel.

Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.

Also in Feedback and overlays: Modal, Drawer, Toast, Alert, Popover. Used in the patterns Forms and overlays.

Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).