Feedback toasts
Components: Toaster, ToastActions, Button, Alert, Banner, Dialog, FieldError
A toast reports the result of the user's last action, then leaves on its own.
When to use
If the message is the only place the user learns something important, do not use a toast. It disappears.
Rules
Type and layout
- If the user's own mutation finished, use
type: 'default'(no icon). A delete confirmed in aDialogis a finished mutation. - Otherwise use
'success','error','warning'(finished with a caveat) or'info'(neutral notice). - Exception: save toasts on a settings page use
type: 'success'. See Settings page. - Always set
type. Without it the toast renders as'info'with a blue icon. - A
descriptionalways switches to theextendedlayout (title over description, 10000 ms), even withvariant: 'simple'. Without it the toast is one 48px row, 5000 ms. iconreplaces the type icon and takes the type color unless it sets its owntext-*class.
Placement and spacing
Toasterowns position (bottom center), 24px padding, 12px gaps and layering above every drawer and dialog. Never wrap it in a positioned element.Toastowns its padding and width (256–560px). Never add spacing or width to toast content.- Three toasts show at once; hover expands the stack and pauses every timer.
- Mount one
Toasterat the app root. Never mount a second.
Loading and updates
- If you create a
loadingtoast, always resolve it withupdateordismiss. It has no timer and never leaves on its own. - If an
updateadds adescription, also passduration: 10000. The timer is fixed atcreate. - Pass
closable: falseonly to aloadingtoast the user must not lose. - If the user can repeat an action (copy, save), pass a stable
idso the toast updates instead of stacking.
Copy
- Use sentence case and name the object, not "Success" or "Done". Never end a title with a period or "!".
- If the error text is long, put the action in
titleand the cause indescription. - Never pre-truncate copy; it clamps with a tooltip.
Behavior
- Fire one toast per user action. A bulk action fires one toast for the batch ("3 users deleted").
- If a
Dialogconfirmed the action, close the dialog first, then fire the toast. - Use
actionsonly for a next step after create, one action (two max), each a<Button variant='secondary' size='small' color='neutral-alt'>insideToastActions. - Never make Undo, Confirm or Retry available only in a toast.
Imports
- Import
useToastfrom@wallarm-org/design-system/Toast. It is not exported from the package root. - Outside React, use
toaster.create(options)andtoaster.update(id, options).
Examples
Confirm a finished mutation with a plain toast. A delete confirmed in a dialog closes the dialog first.
The whole page, with every toast from the one app-root Toaster: create, then send test, copy
link and delete from each row's menu. The parts below show each toast on its own.
Offer one next step after create.
The description switches the toast to the extended layout, so it stays 10000 ms.
Turn a loading toast into the result in place.
The loading toast has no timer; the 5000 ms timer starts when update resolves it.
If the failure adds a description, extend the timer in the same update.
The action goes in title and the provider's cause in description.
Reuse an id so repeated clicks update one toast instead of stacking.
If the clipboard is blocked, the same id turns the toast into an error.
States
What your app owns
- Toast copy, firing after the request resolves, resolving every
loadingtoast, and stable ids.
These do not exist:
- Placement or visible-count props.
Toastertakes no props. - An Undo helper or a promise helper on
useToast. - Rich text.
titleanddescriptionare strings. classNameortestIdoptions. The toast root getsdata-testidequal to itsid, so passidto locate it in tests.- An exported duration constant. Use the literals 5000 and 10000.
Related
- Confirmation dialogs: the dialog before most toasts.
- Settings page: autosave fires a "<Field> updated" toast.
- Create and edit forms: the create toast with a next-step action.
- Layering: why toasts paint above drawers and dialogs.