Use a prompt modal to ask users to provide information before they continue. To display a prompt modal in Lightning Experience, import
LightningPrompt from the
lightning/prompt module, and call
LightningPrompt.open() with your desired attributes.
This prompt modal is an alternative to the native
window.prompt() function, which isn’t supported for cross-origin iframes in Chrome and Safari. Unlike the native prompt function,
LightningPrompt.open() doesn't halt execution on the page, it returns a Promise. Use
.then() for any code you want to execute after the modal is closed.
This example component creates a button that opens the prompt modal UI that you see in the screenshot.
LightningPrompt event with
defaultValue attributes. If the user enters text and clicks OK in the prompt, the
.open() function returns a promise that resolves to the input value. If the user clicks Cancel, the function returns a promise that resolves to
For information about the attributes for the prompt modal, see the Component Reference.