--- templateEngineOverride: njk layout: layouts/page.njk title: Alert Dialog description: A modal dialog that interrupts the user with important content and expects a response. toc: - label: Usage id: usage children: - label: HTML id: usage-html - label: Jinja and Nunjucks id: usage-macro --- {% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %} {% from "dialog.njk" import dialog %} {% set code_html %} {% set footer %} {% endset %} {{ dialog( id="alert-dialog", title="Are you absolutely sure?", description="This action cannot be undone. This will permanently delete your account and remove your data from our servers.", trigger="Open alert dialog", trigger_attrs={"class": "btn-outline"}, footer=footer, close_button=false, close_on_overlay_click=false ) }} {% endset %} {{ code_preview("alert-dialog", code_html | prettyHtml) }}
The Alert Dialog component is identical to Dialog except for two small differences: we do not display a close button and we do not let the user close the dialog when clicking on the backdrop (no onclick attribute on the <dialog> or the <article> elements).
The component has the following HTML structure:
<button type="button"> OptionalshowModal() method).<dialog class="dialog" id="{ DIALOG_ID }">aria-labelledby="{ TITLE_ID }": linked to by the aria-labelledby attribute of the dialog.aria-describedby="{ DESCRIPTION_ID }": linked to by the aria-describedby attribute of the <dialog>.<article><header><h2>id if you use the aria-labelledby attribute on the <dialog>.<p> Optionalid if you use the aria-describedby attribute on the <dialog>.<section> Optional<footer> OptionalYou can use the dialog() Nunjucks or Jinja macro for this component. Make sure to set close_on_overlay_click and close_button to False (or false for Nunjucks).