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;
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.