Sweet Alerts

Show custom alerts and prompts

SweetAlert is a great package to show custom and beautifully designed alerts, prompts etc. It can afford custom CSS in the UI as well as in animation, which makes it a cool feature to be added to almost all your mobile and web apps.

Installation

The package can be installed with npm using

$ npm install sweetalert2

Usage

You can import Sweetalert in your page using

import Swal from 'sweetalert2';

and then show a custom alert using something like this (JSON options can be modified as you want. Check this for more options)

Swal.fire(
      {
        title: 'Good job!',
        text: 'You clicked the button!',
        type: 'success',
        heightAuto: false
      }
    );

Last updated