--- layout: layouts/component.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: Default id: usage-default - label: Jinja or Nunjucks id: usage-jinja --- {% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %} {% from "components/dialog.njk" import dialog %} {% set code %}{% 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 | prettyHtml) }}
The Alert Dialog component uses the same Alpine.js code as the Dialog component with one small difference: we set initialCloseOnOverlayClick to false to prevent the dialog from closing when the overlay is clicked.
If you use Jinja (or Nunjucks), you can use the dialog() macro directly, making sure to set close_on_overlay_click to False (or false for Nunjucks).