SweetAlert alternatives and similar libraries
Based on the "Modals and Popups" category.
Alternatively, view SweetAlert alternatives based on common mentions on social networks and blogs.
-
sweetalert2
A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. -
Magnific-Popup
Light and responsive lightbox script with focus on performance. -
fancyBox
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable. -
X-editable
In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery -
tether
A positioning engine to make overlays, tooltips and dropdowns better -
lightGallery
A customizable, modular, responsive, lightbox gallery plugin. -
vex
A modern dialog library which is highly configurable and easy to style. #hubspot-open-source -
screenfull.js
Simple wrapper for cross-browser usage of the JavaScript Fullscreen API -
bootstrap-modal
Extends the default Bootstrap Modal class. Responsive, stackable, ajax and more. -
Bootbox
Wrappers for JavaScript alert(), confirm() and other flexible dialogs using Twitter's bootstrap framework -
lightgallery.js
Full featured JavaScript image & video gallery. No dependencies -
baguetteBox.js
:zap: Simple and easy to use lightbox script written in pure JavaScript -
iziModal
Elegant, responsive, flexible and lightweight modal plugin with jQuery. -
jquery.avgrund.js
Avgrund is jQuery plugin with new modal concept for popups -
jBox
jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries and more. -
GLightbox
Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes -
🦞 Modali
A delightful modal dialog component for React, built from the ground up to support React Hooks. -
hColumns
jQuery.hColumns is a jQuery plugin that looks like Mac OS X Finder's column view for the hierarchical data. -
F$D€
F$D€ - Client not paid? Add opacity to the body tag and increase it every day until their site completely fades away -
ModalSquared.js
ModalSquared.js is a super small less than a 1kb library for showing and hiding modals.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SweetAlert or a related project?
README
A beautiful replacement for JavaScript's "alert"
Installation
$ npm install --save sweetalert
Usage
import swal from 'sweetalert';
swal("Hello world!");
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 surprises!
Guides
Documentation
Examples
An error message:
swal("Oops!", "Something went wrong!", "error");
A warning message, with a function attached to the confirm message:
- Using promises:
javascript swal({ title: "Are you sure?", text: "Are you sure that you want to leave this page?", icon: "warning", dangerMode: true, }) .then(willDelete => { if (willDelete) { swal("Deleted!", "Your imaginary file has been deleted!", "success"); } });
- Using async/await: ```javascript const willDelete = await swal({ title: "Are you sure?", text: "Are you sure that you want to delete this file?", icon: "warning", dangerMode: true, });
if (willDelete) { swal("Deleted!", "Your imaginary file has been deleted!", "success"); }
### A prompt modal, where the user's input is logged:
- Using promises:
```javascript
swal("Type something:", {
content: "input",
})
.then((value) => {
swal(`You typed: ${value}`);
});
- Using async/await: ```javascript const value = await swal("Type something:", { content: "input", });
swal(You typed: ${value}
);
### In combination with Fetch:
- Using promises:
```javascript
swal({
text: "Wanna log some information about Bulbasaur?",
button: {
text: "Search!",
closeModal: false,
},
})
.then(willSearch => {
if (willSearch) {
return fetch("http://pokeapi.co/api/v2/pokemon/1");
}
})
.then(result => result.json())
.then(json => console.log(json))
.catch(err => {
swal("Oops!", "Seems like we couldn't fetch the info", "error");
});
- Using async/await: ```javascript const willSearch = await swal({ text: "Wanna log some information about Bulbasaur?", button: { text: "Search!", closeModal: false, }, });
if (willSearch) { try { const result = await fetch("http://pokeapi.co/api/v2/pokemon/1"); const json = await result.json(); console.log(json); } catch (err) { swal("Oops!", "Seems like we couldn't fetch the info", "error"); } }
## Using with React
SweetAlert has tools for [integrating with your favourite rendering library.](https://sweetalert.js.org/guides/#using-with-libraries).
If you're using React, you can install [SweetAlert with React](https://www.npmjs.com/package/@sweetalert/with-react) in addition to the main library, and easily add React components to your alerts like this:
```javascript
import React from 'react'
import swal from '@sweetalert/with-react'
swal(
<div>
<h1>Hello world!</h1>
<p>
This is now rendered with JSX!
</p>
</div>
)
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]
*Note that all licence references and agreements mentioned in the SweetAlert README section above
are relevant to that project's source code only.