👉 Upgrading from v6.x to v7.x? Read the release notes!
npm install --save sweetalert2
bower install --save sweetalert2
Or download from CDN: jsdelivr.com/package/npm/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 =
It's possible to import JS and CSS separately, e.g. if you need to customize styles:
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-react-content - React integration
- sweetalert2-webpack-demo - webpack demo
- sweetalert2-parcel-demo - overriding SCSS variables demo
Related community projects
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
|SheetJS LLC||Unique-P GmbH|
Has SweetAlert2 helped you create an amazing application? You can show your support by making a donation in one of several ways: