3.1 KiB
3.1 KiB
Toast
A toast notification element that displays temporary messages with optional icons and auto-hide functionality. The element is always visible but only renders content when a message is shown.
Extends: VisualElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| title | string | "" | The title text of the toast |
| message | string | "" | The message text of the toast |
| duration | number | 3 | Duration in seconds before the toast auto-hides |
| toastType | string | "default" | Type of toast: default, success, error, warning, info |
| autoHide | boolean | true | Whether the toast should automatically hide after duration |
| active | boolean | false | Whether the toast is currently showing a message |
| colorMap | table | Map | of toast types to their colors |
Functions
| Method | Returns | Description |
|---|---|---|
| Toast:show | Toast | Shows a toast message |
| Toast:hide | Toast | Hides the toast |
| Toast:success | Toast | Shows a success toast |
| Toast:error | Toast | Shows an error toast |
| Toast:warning | Toast | Shows a warning toast |
| Toast:info | Toast | Shows an info toast |
Toast:show(titleOrMessage, messageOrDuration?, duration?)
Shows a toast message
Parameters
titleOrMessagestringThe title (if message provided) or the message (if no message)messageOrDuration(optional)string|numberThe message (if string) or duration (if number)duration(optional)numberDuration in seconds
Returns
ToastselfThe Toast instance
Toast:hide()
Hides the toast
Returns
ToastselfThe Toast instance
Toast:success(titleOrMessage, messageOrDuration?, duration?)
Shows a success toast
Parameters
titleOrMessagestringThe title or messagemessageOrDuration(optional)string|numberThe message or durationduration(optional)numberDuration in seconds
Returns
ToastselfThe Toast instance
Toast:error(titleOrMessage, messageOrDuration?, duration?)
Shows an error toast
Parameters
titleOrMessagestringThe title or messagemessageOrDuration(optional)string|numberThe message or durationduration(optional)numberDuration in seconds
Returns
ToastselfThe Toast instance
Toast:warning(titleOrMessage, messageOrDuration?, duration?)
Shows a warning toast
Parameters
titleOrMessagestringThe title or messagemessageOrDuration(optional)string|numberThe message or durationduration(optional)numberDuration in seconds
Returns
ToastselfThe Toast instance
Toast:info(titleOrMessage, messageOrDuration?, duration?)
Shows an info toast
Parameters
titleOrMessagestringThe title or messagemessageOrDuration(optional)string|numberThe message or durationduration(optional)numberDuration in seconds
Returns
ToastselfThe Toast instance