---
updatedAt: 2025-07-15T08:36:55.000Z
agentTools:
  projectIndex: https://docs.appery.io/llms.txt
---

# Ionic SweetAlert Plugin App

The tutorial demonstrates how to use the ***SweetAlert2*** external module to display modal windows in your Ionic app.

Using the ***[SweetAlert2](https://sweetalert2.github.io/#examples)*** module, you can create custom popups: success messages, error messages, warning modals, confirm modals, custom notifications, and prompt windows.

<HTMLBlock>{`
<div style="border-width:1px;border-style:solid;width:377px;border-color:grey;">
      <iframe src="https://ionicsweetalert.app.appery.io/#/sweetalertscreen" seamless="seamless" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:667px;width:375px;top:0px;left:0px;right:0px;bottom:0px"></iframe>
</div>
`}</HTMLBlock>

Also, your ***SweetAlert2*** modules can be easily customized.

## SweetAlert Module

You can learn how to add an external `npm` module to the app from [this guide](https://sweetalert2.github.io/#examples).

For more information on how to customize modal's content, visit the [SweetAlert docs page](https://sweetalert2.github.io/#examples).

# Getting the *Ionic Sweet Alert App*

Getting the Ionic app is really fast and easy as the app is available as a [Sweet Alert plugin](https://docs.appery.io/docs/apperyio-utilities#sweet-alert) inside the **[App Builder](https://docs.appery.io/docs/apperyio-visual-builder)**.

1. From the **[Apps](https://appery.io/app/projects)** tab, click **[Create new app](https://docs.appery.io/docs/1-creating-an-app-ui-palette#creating-new-app)**.
2. Select ***[Ionic Blank](https://docs.appery.io/docs/ionic-5-app-templates#ionic-5-blank)*** for the application type, enter the app name, and click the **Create** button.
3. When the visual **[App Builder](https://docs.appery.io/docs/apperyio-visual-builder)** loads, click **CREATE NEW > From Plugin**.
4. Under **Utilities**, select **[SweetAlert](https://docs.appery.io/docs/apperyio-examples#database-login-and-signup)**.
5. Click **Import selected plugins**:

<Image align="center" className="border" border={true} src="https://files.readme.io/c036d05-2023-03-15_11-53-42.png" />

The app is almost ready for testing and there is one thing you need to do before you can test: set the **SweetAlertScreen** as the default route in **[Routing](https://docs.appery.io/docs/4-routing-and-navigation#using-routing)** and save the changes:

<Image align="center" className="border" border={true} src="https://files.readme.io/b6db059-2023-03-15_11-54-38.png" />

> 🚧 Important!
>
> If you skip the above step, the starting page of the app will be the default **[Screen1](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#pages-screens)** page and not **SweetAlertScreen** so, you will not be able to test the alerts!

To launch the app in the browser, click the **TEST** button in the **[App Builder Toolbar](https://docs.appery.io/docs/apperyio-visual-builder#toolbar)**:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/c3ade75-Animation4.gif" />

But if you are interested in how the plugin was created, please check out the steps below.

# Creating New App

1. From the **[Apps](https://appery.io/app/projects)** tab, click **[Create new app](https://docs.appery.io/docs/1-creating-an-app-ui-palette#creating-new-app)**.
2. Select ***[Ionic Blank](https://docs.appery.io/docs/ionic-5-app-templates#ionic-5-blank)*** for the application type, enter, enter an app name, and click **Create**.

## Adding Dependencies

1. On the left side, unfold the **[Project Tab](https://docs.appery.io/docs/apperyio-visual-builder#project-tab)** folder and go to **App Settings >[Npm modules](https://docs.appery.io/docs/appbuilder-app-settings#npm-modules)**.
2. Add `sweetalert2` as an app **Dependency** and set `11.7.3` for its version:

<Image title="2023-03-15_11-56-31.png" alt={1303} align="center" border={true} src="https://files.readme.io/07268cd-2023-03-15_11-56-31.png">
  Adding Dependency
</Image>

3. Then, choose **[SweetAlertScreen](https://docs.appery.io/docs/2-creating-an-app-ui-pages-and-tabs#pages-screens)** page from the **Pages** folder and open its **[CODE](https://docs.appery.io/docs/apperyio-visual-builder#code-panel)** panel.
4. In the **Custom includes** block, add an include with **Name** = `Swal` and  `sweetalert2` for its path:

<Image title="2023-03-15_11-59-40.png" alt={1055} align="center" border={true} src="https://files.readme.io/f45037f-2023-03-15_11-59-40.png">
  Custom Includes
</Image>

## Creating App UI

1. Now, navigate to the page **[DESIGN](https://docs.appery.io/docs/apperyio-visual-builder#design-panel)** panel. Click on the **[Toolbar title](https://docs.appery.io/docs/ionic-5-ui-components-properties#toolbar-title)** in the app screen and change it to **Sweet Alert** by changing the **Common > Text** property on the right menu of the **[PROPERTIES](https://docs.appery.io/docs/1-creating-an-app-ui-palette#properties-overview)** panel:

<Image title="2023-03-15_12-08-29.png" alt={1912} align="center" border={true} src="https://files.readme.io/02bc159-2023-03-15_12-08-29.png">
  App View
</Image>

2. Drag the **[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)** component and drop it to the screen, then change its **Text** property to ***Alert***.\
   The resulting app UI is very simple:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/33218ca-2023-03-15_12-10-16.png" />

## Application Logic

1. Expand the **[EVENTS](https://docs.appery.io/docs/apperyio-visual-builder#events-tab)** tab from the bottom.
2. There, for the **\*[Button](https://docs.appery.io/docs/ionic-5-ui-components-properties#button)**&#x31; component, select the **Click** event, and for action, set ***[Run TypeScript](https://docs.appery.io/docs/5-event-handling#run-typescript)*** with inserting the following code:

```typescript
Swal.fire({
  title: "Good job!",
  text: "You've found out how to use Sweet Alerts module!",
  icon: 'info',
  confirmButtonText: 'Cool',
  heightAuto:false
});
```

<Image align="center" className="border" border={true} src="https://files.readme.io/ce7b49b-2023-03-15_12-23-05.png" />

> 🚧 Important: *heightAuto:false*!
>
> You are free to use any code you like (can look for samples at <https://sweetalert2.github.io/>) but make sure you add the line `heightAuto:false` to your code.

## App Testing

Now, you are ready to test your app. Сlick the **TEST** button in the **App Builder[Toolbar](https://docs.appery.io/docs/apperyio-visual-builder#toolbar)** to launch your app in the browser.\
After the app starts in the web browser, click the **Alert** button to see the alert:

<Image align="center" className="border" width="smart" border={true} src="https://files.readme.io/40951e1-Animation4.gif" />

# Testing App

When your app version is ready, you might also like to [test](https://docs.appery.io/docs/9-testing-your-app) it on the device.

> 👍 Appery.io Tester App
>
> A great option to quickly test the app on the device is to use our **Appery.io Tester** app.\
> The app is free and available for both [iOS](https://apps.apple.com/app/id737478069) and [Android](https://play.google.com/store/apps/details?id=io.appery.tester\&hl=en).\
> You can check out [this](https://docs.appery.io/docs/apperyio-tester-app) page to learn more about using the **Appery.io Tester** app.