Confirm
lightning:confirm
A modal that asks the user to respond before they continue. This component requires API version 54.0 and later.
For Aura components only. For LWC development, use lightning-confirm.
For Use In
Lightning Experience, Experience Builder Sites, Lightning Out (Beta), Standalone Lightning App
The lightning:confirm library lets you create an confirm modal within your component. Use .openConfirm in your components to ask the user to provide information before they continue.
Use lightning:confirm instead of the native window.confirm() for a more consistent user experience. They have similar functions, but lightning:confirm works in cross-origin iframes, where the .confirm() method is no longer supported in Chrome and Safari. Unlike window.confirm(), .openConfirm 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 confirm has closed.
To create a confirm in your Aura component, import lightning:confirm, and call .openConfirm. Define the confirm's style in the component helper.
This component uses the Salesforce Lightning Design System (SLDS) prompt blueprint .
LightningConfirm supports the following attributes:
message: Message text that displays in the confirm.label: Header text, also used as thearia-label. Default string isConfirm.variant: Two values,headerandheaderless. Default value isheader.theme: Color theme for the header.
The theme attribute supports the following options from SLDS:
message: Message text that displays in the prompt.label: Header text, also used as thearia-label. Default string is "Confirm".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:prompt uses the default theme.