npm install --save sweetalert2
Or grab from jsdelivr CDN :
<!-- Include a polyfill for ES6 Promises (optional) for IE11 and UC 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:
* 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: