Skip to main content

Alert Type

This document describes the Alert which contains data for one alert object.

Type Definitions​

Alert​

type Alert = {
id: string;
type: AlertType;
display?: AlertDisplay;
title?: string;
message?: string;
duration?: AlertDuration;
onClose?: (alert: Alert) => void;
};
  • id: Autogenerated when creating the alert.
  • onClose: An optional callback function.

AlertType​

export type AlertType = "info" | "success" | "warning" | "error";

Based on what the selected type of the alert is, it will be rendered differently:

AlertDuration​

export type AlertDuration = number | "auto";
  • The number value needs to be in milliseconds.
  • The auto value will calculate the duration depending on the length of the message.

AlertDisplay​

export type AlertDisplay = "default" | "prominent";
  • default: A small alert in the corner of the screen (from the alertsPlugin position and align).
  • prominent: A modal in the center of the screen with a Close button. It does not close automatically. Useful for errors that the user should not miss.

The default value per alert type can be set with the defaultDisplay option of the alertsPlugin.