Toast
A notification component that displays temporary messages to users, typically for feedback on actions or system status.
Basic
Call a method from useToast to show a toast. Toasts appear in ToastRenderer, so render it once near the root of the app.
Types
success and warning toasts show an icon. progress and loading toasts stay open until they are dismissed; see Progress and loading.
Duration
duration sets how long a toast stays open, in milliseconds. The default is 3500. The timer pauses while the pointer is over the toasts.
With actions
actionLabel and onAction add a button to the toast. The toast closes after the action runs. With a description, the button sits under it by default; set actionPlacement: 'inline' to keep it beside the text.
Progress and loading
toast.progress() shows a progress bar under the description and has no close button. Update it with toast.updateProgress(id, progress) and close it with toast.dismiss(id). toast.loading() shows a spinner and stays open until it is closed.
Dismiss
Set duration: 0 to keep a toast open until it is closed. toast.dismiss(id) closes a toast from code, using the id the method returned. onDismiss runs only when the person closes the toast with the close button or a swipe.
Toast Options
Custom identifier for the toast (auto-generated if omitted)
The main title of the toast. Without it, the description becomes the title, or a default title for the type is used
The description text of the toast notification
Duration in milliseconds before the toast auto-dismisses (0 = persistent). Ignored for progress and loading toasts
Default: 3500
The type of toast notification. The toast methods set it for you
Default: default
Label for the action button. Shown only together with onAction
Callback fired when the action button is clicked. The toast closes after it runs
Where the action button sits when there is a description: under it, or beside the text
Default: stacked
Callback fired when the person closes the toast with the close button or a swipe. Not called when the timer ends, the action runs, or code dismisses it
Progress value (0-100) for progress toasts. The bar shows only with a description
Default: 0
Custom icon to display in the toast. Pass null to hide the icon of the type
How many lines of description copy to show
Default: 2
Masks the toast's text in session replay. Screen readers then hear only the heading, so keep names in the description
Toast Methods
Shows a default toast and returns its id
Shows a success toast and returns its id
Shows a warning toast and returns its id
Shows a default toast and returns its id
Shows a progress toast that stays open until dismissed. It has no close button
Shows a loading toast that stays open until it is closed
Dismisses a toast by id
Updates a progress toast's value and, optionally, its description