show-alert

The action.show-alert provides a way to notify users about important information in your app, you can choose to show the alert as a toast for lightweight updates, or a modal for important messages. Alerts can be customized with styling, icons, and interactive elements, allowing you to tailor them to different scenarios.

The action.show-alert is considered a background action, meaning it can run automatically or silently without interrupting the current flow. Background actions typically occur behind the scenes, such as syncing data, saving changes, uploading files, or refreshing content.

In most cases, show-alert is configured to run in response to an event such as onPress, onFocus, onLoad, or onRefresh.

The alert may not always be triggered directly by the user. Instead, it can be triggered automatically after another action completes. For example, when a user submits a form, the app might attempt to save the data in the background, and if that save fails, action.show-alert is triggered to notify the user of the error.

Example use cases include:

  • Error handling: Display a retry prompt when a payment fails.

  • Login feedback: Highlight invalid credentials or missing permissions.

  • Critical confirmations: Require approval before deleting a record or submitting an expense.

  • Auto-dismiss functionality for non-critical notifications.

Configuration options

Some properties are common to all components, see Common component propertiesarrow-up-right for a list and their configuration options.

Core Structure

title

The main heading text displayed at the top of the alert. It should be concise and clearly state the purpose of the message.

presentAs

Specifies how the alert is presented to the user. Options include:

  • toast (default): For brief, lightweight notifications.

  • modal: For important messages that require attention and may include additional information. Modal alerts are more disruptive since they block the UI and are typically used for critical information.

Other options

action

Interactive buttons or controls displayed within the alert let users respond or take specific actions. Use IntelliSense to see the list of available actions.

description

The detailed message content that explains the alert’s purpose, provides instructions, or delivers additional information to the user.

dismiss

Configures how users can dismiss the alert. You can enable a gesture dismissal and set an automatic dismissal time.

  • autoAfter - specify the number of seconds after which the alert is automatically dismissed. Has no effect when dismiss is disabled.

  • isEnabled - When set to true (default), allowing manual dismissal by swiping down. When set to false, the alert cannot be dismissed manually.

group

Grouping allows you to manage multiple alerts under a shared identifier. This ensures that only one alert from a group is visible at a time, preventing alert overload and improving the user experience. id - Identifier for the alert group. Only one alert per group can be visible at a time. If a new alert with the same group ID is triggered while another is active, it will be skipped.

icon

The icon displayed alongside the alert content provides visual context and helps users recognize the alert’s type or purpose. The alert’s style property determines the icon color. If no style is set, the default isWarning style is applied.

style

Visual styling options let you set the tone of the alert:

  • isPositive (success/confirmation)

  • isNegative (error) styling to convey the appropriate tone and urgency.

  • isWarning (warning) styling is used by default.

subtitle

Secondary text that appears below the title, providing additional context or supplementary information.

Considerations

  • The action.show-alert is only configurable in an event such as onPress , OnFocus, onLoad or onRefresh.

  • When the show-alert is shown as a toast, tap on the toast to view additional details configured in the description property.

Examples and code snippets

Show-alert as a toast

Show alert as a toast
Show alert as a toast

This example demonstrates an alert configured to display as a toast. It uses a negative style and a custom icon that supports the context of the message. The toast shows the title, subtitle, icon, and available actions at a glance. When the user taps on the toast, the full alert is revealed, including the description field, which can be configured as either static text or dynamically populated using an expression.

Show-alert as a modal

Show alert as a modal
Show alert as a modal

This example demonstrates an alert configured to display as a modal. It uses a positive style and a custom icon that supports the context of the message. The modal shows the title, subtitle, description, icon, and available actions at a glance. The description field can be configured as either static text or dynamically populated using an expression.

Show-alert with actions

This example demonstrates how to configure an alert that evaluates a user's app subscription status. If the subscription has expired, an alert is triggered on the onLoad event in the index.jigx file, displaying a message with an action button that prompts the user to provide billing information and subscribe. The alert leverages the action.show-alert , with a condition set through the when property, reading from a custom subscription variable managed in Jigx Management. Importantly, the alert cannot be dismissed as the dismiss: isEnabled is set to false, compelling the user to either subscribe or exit the app.

Show Alert with an action - modal
Show alert with an action - modal
Show alert with an action - toast
Show alert with an action - toast

Show-alert with styling onFocus

This example uses the onFocus event to notify (alert) the salesperson that the sales order requires the customer’s signature. The alert can be displayed as either a toast or a modal and is styled positively, as it serves as an informative reminder rather than an error.

Show-alert with icons and styling onChange

This example uses the onChange event to alert the worker that the selected tool is unavailable. The alert can be displayed as a toast or a modal and is styled negatively, with a clear icon to reinforce that the selection is not allowed. When shown as a toast, the worker can tap it to view additional details.

Alert shown as a modal
Alert shown as a modal
Alert shown as a toast
Alert shown as a toast, tap for more details

Show-alert with automatic dismissal

This example illustrates how to display a warning alert to workers when specific jobs require PPE (Personal Protective Equipment). Each job is listed with an icon and a "Select" button. Upon selection, if the job necessitates PPE, a non-blocking toast alert appears detailing the required PPE items, reinforcing the importance of safety compliance. The alert is styled with a warning indication and is configured to automatically dismiss after three seconds, ensuring that the alert is noticeable without interrupting the workflow.

Dismiss alert after 3 seconds
Dismiss alert after 3 seconds - Modal
Dismiss alert after 3 seconds - toast
Dismiss alert after 3 seconds - Toast

Show-alert with group id

Show-alert in a REST function

Last updated

Was this helpful?