FIXED JSDOC ISSUE!
A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
:shipit: The author of SweetAlert2 (@limonte) is looking for short-term to medium-term working contracts in front-end, preferably OSS.
👉 Upgrading from v8.x to v9.x? Read the release notes!
If you're upgrading from v7.x, please upgrade from v7 to v8 first!
If you're upgrading from v6.x, please upgrade from v6 to v7 first!
👉 Migrating from SweetAlert? SweetAlert 1.x to SweetAlert2 migration guide
Installation
npm install --save ngx-angular8-sweetalert2
Or grab from jsdelivr CDN :
Usage
<!-- Include a polyfill for ES6 Promises (optional) for IE11 -->
You can also include the stylesheet separately if desired:
Or:
// ES6 Modules or TypeScript // CommonJSconst Swal =
Or with JS modules:
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.
Examples
The most basic message:
Swal
A message signaling an error:
Swal
Handling the result of SweetAlert2 modal:
Swal
Go here to see the docs and more examples ↗
Browser compatibility
IE11* | Edge | Chrome | Firefox | Safari | Opera | 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.