Use a confirm modal to ask users to respond before they continue. The confirm modal is displayed as a dialog on top of the page content using an overlay.
To display a confirm modal in Lightning Experience, import
LightningConfirm from the
lightning/confirm module, and call
LightningConfirm.open() with your desired attributes.
LightningConfirm is an alternative to the native
window.confirm() function, which isn’t supported for cross-origin iframes in Chrome and Safari. Unlike the native confirm function,
LightningConfirm.open() doesn't halt execution on the page, it returns a promise. Use
.then() for any code you want to execute after the confirm modal is closed.
This example component creates a button that opens the confirm modal that you see in the screenshot.
LightningConfirm event with
label attributes. The
.open() function returns a promise that resolves to
true when you click OK and
false when you click Cancel.
For information about the attributes for
LightningConfirm, see the Component Reference.