Canvas Design System
Main Site Tokens

Toast

Notification toasts for feedback messages. Automatically dismiss after a timeout or can include action buttons.

When to Use

Use Toast when: Confirming a completed action (save, delete, copy), showing non-blocking errors, or providing brief feedback that doesn't require user action.
Don't use when: The message requires user attention or blocks a workflow — use an Alert or Modal instead. Avoid stacking more than 3 toasts at once.

Variants

wsToastSuccess('Changes saved!');
wsToastError('Something went wrong');
wsToastWarning('Please review');
wsToastInfo('New updates');

With Action

Toasts can include an action button for undo or follow-up actions.

wsToast('Item deleted', 'info', {
    action: {
        label: 'Undo',
        onClick: function() { wsToastSuccess('Restored!'); }
    }
});

Custom Duration

The default auto-dismiss time is 4 seconds. Pass duration in milliseconds to customise.

wsToastInfo('Quick toast', { duration: 2000 });
wsToastInfo('Long toast', { duration: 8000 });

JavaScript API

FunctionDescription
wsToast(message, variant, options)Show a toast with full control
wsToastSuccess(message, options)Shorthand for success variant
wsToastError(message, options)Shorthand for error variant
wsToastWarning(message, options)Shorthand for warning variant
wsToastInfo(message, options)Shorthand for info variant

Options

OptionTypeDefaultDescription
messagestringToast message text (required)
variantstringinfosuccess | error | warning | info
durationnumber4000Auto-dismiss time in milliseconds
closablebooltrueShow close button
action.labelstringnullAction button label
action.onClickfunctionnullAction button click handler

PHP Setup

The toast container must be rendered once on the page (usually in the footer). The JS API then creates toasts dynamically inside it.

<?= ws_toast_container() ?>

Anatomy

.ws-toast-container — Fixed-position container (bottom-right)
.ws-toast — Individual toast element
.ws-toast__icon — Variant icon
.ws-toast__message — Message text
.ws-toast__action — Optional action button
.ws-toast__close — Close/dismiss button

CSS Classes

ClassPurpose
.ws-toast-containerFixed container for all toasts
.ws-toastBase toast styles
.ws-toast--successSuccess variant
.ws-toast--errorError variant
.ws-toast--warningWarning variant
.ws-toast--infoInfo variant

Files

FilePurpose
includes/components/helpers.phpws_toast_container() helper function
includes/components/toast.phpToast container template
includes/components/components.cssToast CSS (.ws-toast rules)
includes/components/components.jswsToast() and shorthand functions