Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sweetalert2

Package Overview
Dependencies
Maintainers
1
Versions
735
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweetalert2

A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert

  • 11.15.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
633K
increased by0.11%
Maintainers
1
Weekly downloads
 
Created

What is sweetalert2?

SweetAlert2 is a beautiful, responsive, customizable, and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. It provides a wide range of alert types, including success, error, warning, and information alerts, as well as more complex modal dialogs.

What are sweetalert2's main functionalities?

Basic Alert

Displays a basic alert with a message.

Swal.fire('Hello world!');

Success Alert

Displays a success alert with a title, message, and success icon.

Swal.fire('Good job!', 'You clicked the button!', 'success');

Error Alert

Displays an error alert with a title, message, and error icon.

Swal.fire({ icon: 'error', title: 'Oops...', text: 'Something went wrong!' });

Custom HTML Alert

Displays an alert with custom HTML content, including bold text, links, and custom buttons.

Swal.fire({ title: '<strong>HTML <u>example</u></strong>', icon: 'info', html: 'You can use <b>bold text</b>, <a href="//sweetalert2.github.io">links</a> and other HTML tags', showCloseButton: true, showCancelButton: true, focusConfirm: false, confirmButtonText: '<i class="fa fa-thumbs-up"></i> Great!', confirmButtonAriaLabel: 'Thumbs up, great!', cancelButtonText: '<i class="fa fa-thumbs-down"></i>', cancelButtonAriaLabel: 'Thumbs down' });

Input Alert

Displays an alert with an input field for the user to submit data, and performs an asynchronous operation based on the input.

Swal.fire({ title: 'Submit your Github username', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, confirmButtonText: 'Look up', showLoaderOnConfirm: true, preConfirm: (login) => { return fetch(`//api.github.com/users/${login}`) .then(response => { if (!response.ok) { throw new Error(response.statusText) } return response.json() }) .catch(error => { Swal.showValidationMessage(`Request failed: ${error}`) }) }, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.isConfirmed) { Swal.fire({ title: `${result.value.login}'s avatar`, imageUrl: result.value.avatar_url }) } });

Other packages similar to sweetalert2

Keywords

FAQs

Package last updated on 17 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc