SweetAlerts2 - Nice JavaScript Alerts Library
SweetAlerts2 - Nice JavaScript Alerts Library

A zero dependencies beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript’s popup boxes


You can install SweetAlerts2 via npm

npm install sweetalert2

or by you can grab it via jsdeliver CDN

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>


1. Initialize the plugin by referencing the necessary files:

<script src="sweetalert2.all.min.js"></script>
<!-- Optional: include a polyfill for ES6 Promises for IE11 -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill"></script>

You can also include the stylesheet separately if desired:

<script src="sweetalert2.min.js"></script>
<link rel="stylesheet" href="sweetalert2.min.css">


// ES6 Modules or TypeScript
import Swal from 'sweetalert2'

// CommonJS
const Swal = require('sweetalert2')

It’s possible to import JS and CSS separately, e.g. if you need to customize styles:

import Swal from 'sweetalert2/dist/sweetalert2.js'

import 'sweetalert2/src/sweetalert2.scss'

2. Call the sweetAlert2-function after the page has loaded

  title: 'Error!',
  text: 'Do you want to continue',
  icon: 'error',
  confirmButtonText: 'Cool'

You can go to the official library site to see Alerts Examples, by clicking on this link.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.