Prompt
lightning:prompt
A modal that asks the user to provide information before they continue. This component requires API version 54.0 and later.
For Aura components only. For LWC development, use lightning-prompt.
For Use In
Lightning Experience, Experience Builder Sites, Lightning Out (Beta), Standalone Lightning App
The lightning:prompt library lets you create an prompt modal within your component. Use .openPrompt in your components to ask the user to provide information before they continue.
Use lightning:prompt instead of the native window.prompt() for a more consistent user experience. They have similar functions, but lightning:prompt works in cross-origin iframes, where the .prompt() method is no longer supported in Chrome and Safari. Unlike window.prompt(), .openPrompt doesn't halt execution on the page, it returns a Promise. Use async/await, or .then() for any code you want to execute after the prompt has closed.
To create a prompt in your Aura component, import lightning:prompt, and call .openPrompt. Define the prompt's style in the component helper.
This component uses the Salesforce Lightning Design System (SLDS) prompt blueprint .
lightning:prompt supports the following attributes:
-
message: Message text that displays in the prompt. -
defaultValue: Optional. Initial leading text for the input text box. -
label: Header text, also used as thearia-label. Default string is "Prompt". -
variant: Two values,headerandheaderless. Default value isheader. -
theme: Color theme for the header. Thethemeattribute supports the following options from SLDS:default: whiteshade: grayinverse: dark bluealt-inverse: darker bluesuccess: greeninfo: gray-ish bluewarning: yellowerror: redoffline: black
If an invalid value is provided,
lightning:promptuses thedefaulttheme.