Sweetalert2 is a modern, responsive, and customizable popup library that allows you to create beautiful, user-friendly alert boxes. It's widely used for displaying popups, alerts, and confirmations. This section covers the steps required to include Sweetalert2 in your project:
To install Sweetalert2, run the following command in the root directory of your project:
yarn add sweetalert2 --save
To use Sweetalert2 in your project, you need to include its stylesheet and JavaScript files in your HTML:
<link rel="stylesheet" href="assets/libs/sweetalert2/sweetalert2.min.css"><link/>
<script src="assets/libs/sweetalert2/sweetalert2.min.js"><script/>
Below is an example of the HTML code to create a Sweetalert2 popup. The button triggers a Sweetalert2 alert when clicked:
Here is the JavaScript code that initializes the Sweetalert2 instance. This will trigger a Sweetalert2 popup when the button is clicked:
document.getElementById("basicMessage").addEventListener("click", function() { Swal.fire( { title: 'Good job!', confirmButtonClass: 'btn btn-primary', buttonsStyling: false } ) });
The above JavaScript code does the following:
Be the first to know about new updates and exclusive discounts. No spam, just great offers!
How about
With over 7 years of experienced team, we specialize in delivering custom projects for startups, blue-chip companies, and government agencies. We have successfully completed over 250+ projects, providing tailored solutions that meet the unique needs of each client.
Support© Herozi Design & Develop by Codebucks.