Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Toast
  3. Usage

Toast

Usage

A toast is a transient message: a confirmation, a result, or a soft failure that does not need an answer before the person carries on. Mount one Toaster where the app mounts its other providers, then call toast from anywhere.
When to use
  • Confirmations that need no acknowledgement ("Saved", "Copied").
  • The result of a background task, with an optional follow-up action.
  • A soft failure where a retry is the natural next step and the rest of the screen stays usable.
When not to use
  • A decision the person must make before continuing: use AlertDialog.
  • A message that stays with its content, such as a field error or a page-level notice: use Alert or Banner.
  • A message the person must not miss. A toast leaves on its own. Notifications at different interruption levels belong to the notifications system (CORE-958), not here.
Severity
toast shows a neutral message. toast.info, toast.success, toast.warning, and toast.error set the severity, which picks the icon and its status color and how urgently a screen reader reads the message. toast(message, { severity }) takes the severity as data.
Layout
The icon, the text, and the buttons center on each other when the message is a single line with no description. A toast with a description, or a title that wraps to more than one line, hangs them from the top edge instead, so the icon stays beside the first line. Nothing is configured for this; the toast measures its own text.
Actions
An action is a Button in the toast. Pressing it runs onClick, then dismisses the toast without calling onDismiss. Keep the label to a word or two. A toast does not navigate: do the navigation in onClick.
Updating a toast
Pass an id. A second call with the same id updates the toast in place and restarts its timer instead of stacking another.
Where it shows
A toast shows in the Toaster of the document that owns source, usually the button that was pressed (source: event.currentTarget). A message from a detached window stays in that window when that window has a Toaster; otherwise it goes to the first Toaster mounted. While a modal dialog or modal drawer is open, the stack moves into it so it stays above the dialog and keeps taking input. It moves back when the dialog closes.
Copy
The title, description, action label, region label, and close label are all LocalizedMessage. The component supplies no text.
Previous
Accessibility / Testing with Screen Readers
Next
Toast / API and Development
On this page
When to use
When not to use
Severity
Layout
Actions
Updating a toast
Where it shows
Copy