I'm looking for the best practice to fire a simple Confirm, Prompt or Alert from a component using the LDS (and use the response).

It feels like it should be simple question but I can't find an example.

  • Me too. Good question and for in house development and building prototypes I am not interested in building a custom confirm dialog. I also hope that someday LDS will include this basic UI building block. – Bryan Jun 20 '18 at 1:51

There are notification components documented.

You can roll your own JavaScript here as per specification


You can use one of the toasts or prompt depending on your need.

Please note all code has to be custom .

  • Yes, I had read that information. What I am trying to understand is the best way to initiate the 'alert', and how to handle the fact that the user has clicked OK or Cancel – Charlie May 20 '16 at 14:37
  • Are you using component framework or visualforce ? You will need to throw the buttons there and identify via the button name – Mohith Shrivastava May 20 '16 at 14:50
  • I am writing a lightning component – Charlie May 20 '16 at 14:56
  • Have you started with a code for same that I can look and help you here . – Mohith Shrivastava May 20 '16 at 15:34

If you don't care too much about the looks (LDS) you can leverage the 'normal' javascript alerts by calling them from your lightning component controller:

Component code:

<lightning:buttonIcon name="remove" variant="bare" size="small" iconName="utility:delete" onclick="{!c.removeItem}" alternativeText="remove item" />

Component controller code:

    removeItem: function(component, event, helper) {
        // show a confirm
        if(confirm("Are you sure you want to delete this item?")){
           // perform custom logic here    

  • 1
    Exactly what I need to build a MVP. I was disheartened to know I'd have to build a custom confirm dialog for this most basic UI component. Happy to know the confirm dialog is there and it is more than sufficient for in house development. – Bryan Jun 20 '18 at 1:49

force:showToast has been made available since this question was posted a while back, imo, it is the easiest way to display a notification based on a user action.

showToast : function(component, event, helper) {
    var toastEvent = $A.get("e.force:showToast");
        "title": "Success!",
        "message": "The record has been updated successfully."

There is also the lightning:notificationsLibrary which is basically a SLDS modal component that can be created dynamically to display a message, It is available since API v41.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.