Skip to main content

toast

Usage

import {toast} from "42/ui/components/toasts.js"
const toast = sys42.toast

The toast component is used to display temporary notifications or messages to the user.

Method parameters

ParameterTypeRequiredDefaultDescription
messageString/objectNot if options is presentShort dialog message
optionsObjectNot if message is presentContains all toast configuration properties.

Options

PropertyTypeRequiredDefaultDescription
messageStringYesThe message to display in the toast.
pictoPictoNoA picto element.
containedBooleanNo
iconStringNoIcon path.
labelStringNo
footerStringNo
beforeContentStringNo
closeableBooleanNo
afterContentStringNo
closeOnContextMenuBooleanNo
animateFromObject: {translate: String(percentage), opacity: Number}No{ translate: "100%", opacity: 0 }
timeoutIntegerNo500
animateToObject: {translate: String(percentage), opacity: Number}No
containerHTMLElementNodocument.documentElement

Examples

Basic Toast

const options = {
message: "Hello, World!",
timeout: 3000
};
toast(options);

Toast with Icon and Picto

const options = {
message: "File uploaded successfully!",
icon: "/path/to/icon.png",
picto: "checkmark"
};
toast(options);

Toast with Custom Animation

const options = {
message: "Loading...",
animateFrom: { translate: "-50%", opacity: 0 },
animateTo: { translate: "0%", opacity: 1 },
timeout: 1000
};
toast(options);