Skip to content

API References

Methods to Create Toasts:

These methods are available on the instance of the library. To find the methods available on the instance of the created toast please have a look in the ToastEntry API reference.

Method NameDescription
notify(content: ToastContent, options?: ToastOptions):ToastEntryDisplays and returns the toast
info(content: ToastContent, options?: ToastOptions):ToastEntryDisplays and returns the toast of type info.
success(content: ToastContent, options?: ToastOptions):ToastEntryDisplays and returns the toast of type success
warn(content: ToastContent, options?: ToastOptions):ToastEntryDisplays and returns the toast of type warning
error(content: ToastContent, options?: ToastOptions):ToastEntryDisplays and returns the toast with type error
closeAll()Will close all the toast notifications

ToastContent

It is used as the first parameter of the notify(),success(), info(), warn(), error() and update() methods.

For Example:

js
toast.notify(content: ToastContent, options?: ToastOptions)

ToastContent can be either one of the following type:

string , { title?: Title; message?: ToastMessage; buttons?: Button[]; } or HTMLElement

List of Options (ToastOptions):

Options are optional.

Option NameTypeDescriptionDefault Value
positiontop-left, top-right, top-center, bottom-left, bottom-right, centerPosition of the toast on the screentop-right
animationslide, bounce, fade, zoomAnimation that will be applied once the Toast appears and disappearsslide
typedefault, success, info,warning, errorType of the Toastdefault
designminimal, standard, colorful,gradientDesign of the Toastminimal
themelight, dark, systemColor mode of the Toastlight
durationnumberDuration in millisecond for which the toast is visible3000
autoClosebooleanIf the Toast should closed automatically once Duration is elapsedtrue
hasProgressBarbooleanIf the Toast should have a progressbarfalse
progressnumberIf the Progress Bar is visible then it will be used as starting position of the progress. Value must be between 0 to 1000
isCloseablebooleanIf the Toast should have the close icontrue
containerHTMLElementContainer where the all Toasts will be mounteddocument.body
classNamesstring[]A list of classes which will be added on the Toast[]
hasIconbooleanIf the Toast should have Icon visibletrue
icon{url: string, classes: string[], size: "small or medium or large"}Size of the Icon of the Toastsmall
offset{x: number, y: number}Gap from the nearest edges or the Container. x and y values are treated as px{x:30, y:30}
onShow() => voidWill be called once the Toast is appread in the screen after finising Animation
onClose() => voidWill be called once the Toast is removed from the DOM

Methods and Properties exposed by the Toast:

The Toast implements the ToastEntry interface which offers following methods and Properties:

Method/Property NameDescriptionType
update(content: ToastContent, options?: ToastOptions)Updates the existing toast with new ToastContent and can modify the UI and behavior of that toast by passing configurations as ToastOptions() => {}
close()Closes the toast that was created earlier() => {}
closeAll()Will close all the toast notifications() => {}
mountedInIt is the container Element of type HTMLElement that contains the ToastHTMLElement
elementThe reference of the DOM Node of the ToastHTMLElement
optionsThe options applied on the ToastToastEntry