Toast()
Displays a temporary notification message at the bottom of the screen. Toasts automatically disappear after the specified duration.
Syntax
MaterialSB::Toast(Text.s, Duration = 4000, Flags = #Toast_Default, Color.s = "")
Parameters
| Text.s | The message to display in the toast. |
| Duration | Optional. Display time in milliseconds. Default is 4000 (4 seconds). |
| Flags | Optional. Toast styling flags. |
| Color.s | Optional. Background color using Materialize color classes (e.g., "red", "blue darken-2"). |
Flags
| Flag | Description |
|---|---|
#Toast_Default | Standard rectangular toast (default) |
#Toast_Rounded | Rounded corners on the toast |
Return Value
None.
Remarks
Toasts are non-blocking notifications that appear at the bottom of the viewport. Multiple toasts will stack vertically. Use ToastDismissAll() to immediately dismiss all active toasts.
The toast API changed in MaterializeCSS 2.1.1 to use constructor syntax.
Example
Procedure ShowInfoToast()
MaterialSB::Toast("File saved successfully!", 3000)
EndProcedure
Procedure ShowErrorToast()
MaterialSB::Toast("Error: Connection failed", 5000, MaterialSB::#Toast_Rounded, "red")
EndProcedure
Procedure ShowWarningToast()
MaterialSB::Toast("Warning: Low disk space", 4000, MaterialSB::#Toast_Default, "orange darken-2")
EndProcedure
Procedure DismissAll()
MaterialSB::ToastDismissAll()
EndProcedure
Procedure Main(Success)
If Success
MaterialSB::Row(MaterialSB::#Grid_Container)
MaterialSB::Col(12)
MaterialSB::Button("Show Info Toast", @ShowInfoToast())
MaterialSB::Button("Show Error Toast", @ShowErrorToast(), MaterialSB::#Button_Default)
MaterialSB::Button("Show Warning Toast", @ShowWarningToast(), MaterialSB::#Button_Tonal)
MaterialSB::Button("Dismiss All", @DismissAll(), MaterialSB::#Button_Outlined)
MaterialSB::CloseCurrentParent()
MaterialSB::CloseCurrentParent()
EndIf
EndProcedure
MaterialSB::Download(@Main())