Skip to content

Toast

Imperative global toasts supporting success/error/warning/info/loading states, action buttons, and promise chains; auto-dismisses after 3 seconds by default.

Basic usage

Five types

SuccessErrorWarningInfoLoading

Custom duration

Custom duration

2s5sNo auto-close (0)Close manually

Action buttons

Action buttons

With action buttonNot closable

Position

Position

top-righttop-lefttop-centerbottom-center

Promise chain

Promise chain

Simulate successSimulate failure

API

Methods

MethodDescription
toast.info(options)Info toast, returns { close }
toast.success(options)Success toast, returns { close }
toast.warning(options)Warning toast, returns { close }
toast.error(options)Error toast, returns { close }
toast.loading(options)Loading toast (not closable), returns { close }
toast.promise(promise, opts)Promise chain: loading → success/error
destroyAllToast()Clear all toasts

options

FieldDescriptionTypeDefault
titleTitlestring
descriptionDescriptionstring
actionAction button{ label, onClick }
durationAuto-dismiss duration (ms); 0 keeps it opennumber3000
closableWhether it can be closed manually (loading is always unclosable)booleantrue
positionPosition6 directions such as top-righttop-right
  • error uses role="alert", others use role="status".
  • Multiple toasts share one stack container and stack by position per direction; duration timers are cleaned up on close/unmount with no leaks.