What is the SweetAlert?
Installation of SweetAlert
NPM is the recommended method of installing SweetAlert in conjunction with tools such as BrowserWise or Webpack.
Then, just import it into your project and application:
You can also get a CDN link for the latest version of the library and include it in your webpage using script tags:
Once the library is set up, creating a SweetAlert message is very easy. All you have to do is call the swal() function.
Examples of sweetalert
1. Simple message alert
2. If you pass two arguments to the swal() function, the first will be the title of the model, and the second is the text of the model, shown below
Error and success message
Customize confirm button
You can choose a lot of options to configure your alert code. For example, you can change the text on the confirmation button.
An alert message with a function attached to the "Confirm" button and "cancel" button.
An alert message with the customize icon.
A replacement of the "prompt" function
swal() function with a loader gif button (for a AJAX requests)
With JSX syntax, if you are using SweetAlert, you will need to install React.
After that, it is very easy to import SweetAlert.
The JSX syntax changes the model's content option, so you can still use other features of SweetAlert.