Skip to main content
Version: 5.35.0

Alert

An Alert dialog notifies or warns the user about something. It displays a single button which closes the Alert component.

Usage

The following example displays an Alert message on button click.

<script setup>
import { ref } from 'vue';
import { MbscAlert, MbscButton } from '@mobiscroll/vue';

const isAlertOpen = ref(false);
</script>

<template>
<MbscAlert
title="Cellular Data is Turned Off for 'Safari'"
message="You can turn on cellular data for this app in Settings."
:isOpen="isAlertOpen"
@close="isAlertOpen = false"
/>
<MbscButton @click="isAlertOpen = true">Alert</MbscButton>
</template>

Options

Explore the following API options that help you easily configure the Alert component.

animation

boolean | "pop" | "slide-down" | "slide-up"

Animation to use when the component is opened or closed.

Default value: undefined

cssClass

string

Specifies a custom CSS class for the component.

Default value: undefined

display

"center" | "top" | "bottom"

Controls the positioning of the component.

Default value: undefined

isOpen

boolean

Specifies if the component is opened or not. Use it together with the onClose event, by setting it to false when the component closes.

Default value: undefined

message

string

Message to present.

theme

string

Specifies the visual appearance of the component.

If it is 'auto' or undefined, the theme will automatically be chosen based on the platform. If custom themes are also present, they will take precedence over the built in themes, e.g. if there's an iOS based custom theme, it will be chosen on the iOS platform instead of the default iOS theme.

Supplied themes:

  • 'ios' - iOS theme
  • 'material' - Material theme
  • 'windows' - Windows theme

It's possible to modify theme colors or create custom themes.

info

Make sure that the theme you set is included in the downloaded package.

Default value: undefined

themeVariant

"light" | "dark" | "auto"

Controls which variant of the theme will be used (light or dark).

Possible values:

  • 'light' - Use the light variant of the theme.
  • 'dark' - Use the dark variant of the theme.
  • 'auto' or undefined - Detect the preferred system theme on devices where this is supported.

To use the option with custom themes, make sure to create two custom themes, where the dark version has the same name as the light one, suffixed with '-dark', e.g.: 'my-theme' and 'my-theme-dark'.

Default value: undefined

title

string

Title for the dialog.

Default value: undefined

Localization

The Alert component is fully localized. This covers date and time format, button copy, rtl and more.

okText

string

Text for the button which closes the dialog.

Default value: 'OK'

Events

The Alert component ships with different event hooks for deep customization. Events are triggered through the lifecycle of the component where you can tie in custom functionality and code.

@close

(result: undefined) => void

Triggered when the component is closed.