👉 Upgrading from v6.x to v7.x? Read the release notes!
npm install --save sweetalert2
bower install --save sweetalert2
<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support -->
You can also include the stylesheet separately if desired:
// ES6 Modules or TypeScript// CommonJSconst Swal =
Please note that TypeScript is well-supported, so you don't have to install a third-party declaration file.
The most basic message:
A message signaling an error:
Handling the result of SweetAlert2 modal:
|IE11*||Edge||Chrome||Firefox||Safari||Opera||Android Browser*||UC Browser*|
* ES6 Promise polyfill should be included, see usage example.
Note that SweetAlert2 does not and will not provide support or functionality of any kind on IE10 and lower.
- ngx-sweetalert2 - Angular 4+ integration
- sweetalert2-webpack-demo - webpack demo
- sweetalert2-parcel-demo - overriding SCSS variables demo
Related community projects
- avil13/vue-sweetalert2 - Vue.js wrapper
- softon/sweetalert - Laravel 5 Package
- alex-shamshurin/sweetalert2-react - React component
If you would like to contribute enhancements or fixes, please do the following:
sweetalert2repository and clone it locally.
When in the SweetAlert2 directory, run
yarn installto install dependencies.
To begin active development, run
yarn start. This does several things for you:
- Lints your code
- Builds the
- Serves sandbox.html @ http://localhost:8080/ (browser-sync ui: http://localhost:8081/)
- Serves unit tests @ http://localhost:3000
- Re-lints, re-builds, re-loads and re-tests as necessary when files change
Has SweetAlert2 helped you create an amazing application? You can show your support by making a donation in one of several ways:
- Donate via PayPal
- Donate via Patreon
- Become a backer on OpenCollective
- Become a sponsor on OpenCollective
Thank you to all our backers! 🙏
If you support this project by becoming a sponsor, your logo will show up here with a link to your website.