Skip to content

Instantly share code, notes, and snippets.

@pozil pozil/toaster.cmp
Last active Apr 7, 2019

Embed
What would you like to do?
Lightning - Displaying a system toast with a few lines of code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global">
<div class="slds-m-around--xx-large slds-text-align--center">
<lightning:button label="Fire toast event" onclick="{! c.fireToastEvent }"/>
</div>
</aura:component>
({
fireToastEvent : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": "Success!",
"message": "It works!",
"type": "success"
});
toastEvent.fire();
}
})
@pozil

This comment has been minimized.

Copy link
Owner Author

commented Apr 13, 2017

The toaster component cannot be placed in a standalone Lightning application.
It relies on the Salesforce one.app to properly display toasts.

@pozil

This comment has been minimized.

Copy link
Owner Author

commented Jul 3, 2017

Deploy the component either:

  • as a new Lightning Component tab
  • in an existing Lightning page using the Lightning Application Builder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.