A beautiful replacement for JavaScript's "alert"
Installation
$ npm install --save sweetalert
Usage
; ;
Upgrading from 1.X
Many improvements and breaking changes have been introduced in the 2.0 release. Make sure you read the upgrade guide to avoid nasty suprises!
Guides
Documentation
Examples
An error message:
;
A warning message, with a function attached to the confirm message:
- Using promises:
;
- Using async/await:
const willDelete = await ; if willDelete ;
A prompt modal, where the user's input is logged:
- Using promises:
;
- Using async/await:
const value = await ; ;
In combination with Fetch:
- Using promises:
;
- Using async/await:
const willSearch = await ; if willSearch try const result = await ; const json = await result; console; catch err ;
Using with React
SweetAlert has tools for integrating with your favourite rendering library.
If you're using React, you can install SweetAlert with React in addition to the main library, and easily add React components to your alerts like this:
Read more about integrating with React
Contributing
If you're changing the core library:
- Make changes in the
src
folder. - Preview changes by running
npm run docs
- Submit pull request
If you're changing the documentation:
- Make changes in the
docs-src
folder. - Preview changes by running
npm run docs
- Run
npm run builddocs
to compile the changes to thedocs
folder - Submit pull request
Contributors
This project exists thanks to all the people who contribute. [Contribute].
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]