On this page:

Toast

Toast Container

Preview

index.tsx

Types

Preview

index.tsx

Preview

index.tsx

Preview

index.tsx

Preview

index.tsx

Preview

index.tsx

Duration

Preview

index.tsx

Position

Preview

index.tsx

Important

Preview

index.tsx

Pending

Preview

index.tsx

Design Tokens for Toast

TokenColor forState/Meaning
--par-color-bg-toast-emphasis-high-genericToast backgroundGeneric
--par-color-bg-toast-emphasis-high-informationToast backgroundInformation
--par-color-bg-toast-emphasis-high-affirmativeToast backgroundAffirmative (success)
--par-color-bg-toast-emphasis-high-cautionaryToast backgroundCautionary (warning)
--par-color-bg-toast-emphasis-high-adverseToast backgroundAdverse (error)
--par-color-bg-emphasis-normalToast backgroundNormal emphasis
--par-color-border-toast-emphasis-high-genericToast borderGeneric
--par-color-border-toast-emphasis-high-infoToast borderInformation
--par-color-border-toast-emphasis-high-affirmativeToast borderAffirmative (success)
--par-color-border-toast-emphasis-high-cautionaryToast borderCautionary (warning)
--par-color-border-toast-emphasis-high-adverseToast borderAdverse (error)
--par-color-border-emphasis-normalToast borderNormal emphasis
--par-color-border-progress-bar-genericProgress barGeneric
--par-color-border-progress-bar-infoProgress barInformation
--par-color-border-progress-bar-affirmativeProgress barAffirmative (success)
--par-color-border-progress-bar-cautionaryProgress barCautionary (warning)
--par-color-border-progress-bar-adverseProgress barAdverse (error)

Toast API Reference

<Toast />

PropTypeDefaultDescription
titlestring | ReactNodeTitle text of the toast
messagestring | ReactNodeMain message content
actionReactNodeOptional action element (e.g. button)
kind'generic' | 'information' | 'affirmative' | 'cautionary' | 'adverse''generic'Visual style and purpose of the toast
emphasis'normal' | 'high''high'Emphasis level (visual prominence)
height'flexible' | 'compact''flexible'Height variant (standard or compact)
position'top-right' | 'top-center' | 'bottom-right' | 'bottom-center''top-right'Screen position for the toast
autoDismissbooleanfalseAuto-dismiss after a set duration
durationnumber5000Auto-dismiss duration in milliseconds
pauseOnHoverbooleantruePause auto-dismiss timer on hover
iconReactNodeCustom icon (overrides default)
progressBarbooleanfalseShow a progress bar for auto-dismiss
dismissButtonbooleantrueShow a close (dismiss) button
importancenumber0Priority for stacking/sorting
pendingbooleanfalseShow loading spinner (pending state)
onDismissedfunction ()Callback when toast is dismissed
...divPropsHTMLDivElement propsAll native div props (className, style, ...)

Note: ToastOptions includes all the above props except id and removeToast (which are internal and managed by the system).


toast()

Creates and controls toast notifications programmatically.

Signature:

const myToast = toast(options: ToastOptions): ToastController;

Parameters:

NameTypeDescription
optionsToastOptionsToast options (same as <Toast /> props except id and removeToast).

Returns:

A ToastController object with the following methods:

MethodSignatureDescription
start()() => voidShow the toast
stop()() => voidRemove the toast
update()(options: ToastOptions) => voidUpdate the toast with new options
getDetail()() => ToastOptions & { id: string }Get the current toast detail (including id)

Example:

const myToast = toast({ kind: 'success', message: 'Task completed!' });
myToast.start(); // Show the toast
myToast.update({ message: 'Updated message' }); // Update toast content
myToast.stop(); // Remove the toast

Note: toast() dispatches custom events to control toasts. You must have a <ToastContainer /> mounted in your app for toasts to appear.