Toast
ic.Toast is an ephemeral notification that appears briefly, then auto-dismisses and deletes itself. It is useful for confirming that an action succeeded, warning about a transient condition, or surfacing an error without interrupting the user’s workflow. Multiple toasts stack vertically when shown at the same time.
addOverlay(), not addChild(). The toast auto-deletes after it is dismissed, so you do not need to manage its lifecycle.Variants
Value sets the message text and Variant controls the color accent and default icon. Each variant maps to a semantic meaning: primary for general notifications, success for confirmations, warning for caution, destructive for errors, and info for neutral updates.
Duration, position, and closable
Duration controls how many seconds the toast stays visible before auto-dismissing. Set it to 0 for a persistent toast that the user must close manually. Position places the toast stack at the top or bottom of the viewport, and Closable toggles the X button.
Stacking
When multiple toasts are visible at the same time, they stack vertically in the order they were added. Each toast manages its own timer independently, so they dismiss at different times as their durations expire.
Events
Toast fires a single Closed event when it is dismissed, whether by timeout, close button, or the dismiss() method. After the event fires, the toast automatically deletes itself in MATLAB, so there is no need to clean it up manually.
Custom styling
The toast DOM uses .ic-toast as the root, with .ic-toast__accent for the left color strip, .ic-toast__icon for the variant icon, .ic-toast__message for the text, and .ic-toast__close for the dismiss button. A ::before pseudo-element applies a subtle variant tint over the background.
t = ic.Toast("Value", "Build succeeded!", ...
"Variant", "success", "Duration", 5);
t.css.style(".ic-toast", ...
"background", "#f0fdf4", ...
"border", "1px solid #bbf7d0", ...
"border_radius", "8px", ...
"box_shadow", "0 4px 12px rgba(34, 197, 94, 0.15)");
% Hide the default variant tint overlay
t.css.style(".ic-toast::before", ...
"display", "none");
% Animated progress bar showing time remaining
t.css.keyframes("toast-fill", ...
"from", struct("width", "100%"), ...
"to", struct("width", "0%"));
t.css.style(".ic-toast::after", ...
"content", "''", ...
"position", "absolute", ...
"bottom", "0", ...
"left", "0", ...
"height", "3px", ...
"background", "linear-gradient(90deg, #22c55e, #16a34a)", ...
"animation", "toast-fill 5s linear forwards");
t.css.style(".ic-toast__accent", ...
"display", "none");
t.css.style(".ic-toast__message", ...
"color", "#166534", ...
"font_weight", "500");
t.css.style(".ic-toast__icon", ...
"color", "#16a34a");linear-gradient, backdrop-filter, or newer color functions may not work everywhere. For reference, MATLAB R2024b uses Chromium 104.
Always test your custom styles in the MATLAB version you are targeting, and use canIuse to check compatibility of specific CSS features if you know the browser version MATLAB is using.
Use the Developer Tools component to inspect the DOM structure of each component and find the right selectors for styling.