Files
Basalt2/docs/references/elements/Toast.md
2025-10-30 13:13:21 +00:00

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

  • titleOrMessage string The title (if message provided) or the message (if no message)
  • messageOrDuration (optional) string|number The message (if string) or duration (if number)
  • duration (optional) number Duration in seconds

Returns

  • Toast self The Toast instance

Toast:hide()

Hides the toast

Returns

  • Toast self The Toast instance

Toast:success(titleOrMessage, messageOrDuration?, duration?)

Shows a success toast

Parameters

  • titleOrMessage string The title or message
  • messageOrDuration (optional) string|number The message or duration
  • duration (optional) number Duration in seconds

Returns

  • Toast self The Toast instance

Toast:error(titleOrMessage, messageOrDuration?, duration?)

Shows an error toast

Parameters

  • titleOrMessage string The title or message
  • messageOrDuration (optional) string|number The message or duration
  • duration (optional) number Duration in seconds

Returns

  • Toast self The Toast instance

Toast:warning(titleOrMessage, messageOrDuration?, duration?)

Shows a warning toast

Parameters

  • titleOrMessage string The title or message
  • messageOrDuration (optional) string|number The message or duration
  • duration (optional) number Duration in seconds

Returns

  • Toast self The Toast instance

Toast:info(titleOrMessage, messageOrDuration?, duration?)

Shows an info toast

Parameters

  • titleOrMessage string The title or message
  • messageOrDuration (optional) string|number The message or duration
  • duration (optional) number Duration in seconds

Returns

  • Toast self The Toast instance