Skip to content

Toast

Last updated 6 Nov 2026

NbToast is one toast: an icon, an optional title, a message, an optional action and a close button. It is the leaf.

You almost certainly want NbToaster instead. The host owns everything a notification needs beyond the look of one message: the queue, the shared clock, the visible cap, pause on hover and focus, announcement, dismissal and where focus goes afterwards. Mount <NbToaster /> once, call useToast() from anywhere, and you never render NbToast yourself.

ts
import { useToast } from '@nubisco/ui'

const toast = useToast()
toast.success('Draft saved')

Do not build your own host

A toast host has to get auto-dismiss, the stacking token (--nb-zindex-toast, not --nb-z-toast, which does not exist), role="alert", the variant icon, the action and pause-on-hover all right at once. Each is easy to lose without noticing, which is why the container is library code. If you have a local Toaster.vue, the migration steps are four short ones.

When to use ​

A toast is news that expires. Something finished, the user does not have to answer it, and in thirty seconds it will not matter. Four cases fit.

An action succeeded and there is nothing on screen that says so ​

"Draft saved", "Invitation sent", "3 rows imported". A successful save with no confirmation at all leaves the user pressing the button again to find out whether it worked. A four-word toast is the cheapest fix in this library.

An action failed in a way that is not about the page in front of you ​

A background sync, an export, a request fired from a menu the user has already closed. A failure that belongs to a visible form or a visible page is not a toast; see the table below. An error toast is persistent by default (NB_TOAST_DURATIONS.error is 0), because "it failed" is the beginning of a task, not the end of one.

Something reversible just happened, and you would rather offer undo than ask ​

"Comment deleted" with an Undo action costs one optional click. A confirmation dialog costs one mandatory click, every time, forever. When the delete is genuinely reversible, this is the better design, and it is the only case where a toast is allowed to carry an action. The mechanics (a cta, an explicit duration, and onDismiss telling you the true reason it ended) are in Undo, correctly.

Something changed that the user did not do ​

"Connection restored", "New version available, reload to update". These carry retain: true if they are still true after a navigation.

When not to use ​

Two questions disqualify a toast, and neither is about tone or severity:

  1. Must the user act on it? A toast times out. Anything that must be done cannot live on a surface that removes itself while it is being read.
  2. Must the user be able to re-read it? A toast is gone and unrecoverable. An error code, an ID, a list of what failed, anything the user might paste into a support ticket, cannot be the toast's only home.

If either answer is yes, the message belongs somewhere with a lifetime: not a blocking alert(), and not NbMessage, which is a 12px inline field helper rather than a home for page-level errors.

What you haveUse insteadBecause
A validation errorNbMessage on the fieldThe fix happens at the field. A toast makes the user remember which one
A failure that belongs to the page or the formNbBanner variant="inline", in placeThe user has to see the failure and the thing that failed together, for as long as it takes to fix it
A condition that stays true while the page is openNbBanner variant="callout"A standing fact that expires has been told to the user exactly once, at random
A question that must be answered before anything continuesuseConfirm()A toast cannot block, and it cannot be answered. A toast that "confirms" something confirms nothing
News that outlives the moment and has to be findable laterNbNotificationCenterA toast is gone once read. The notification centre keeps it until the user has dealt with it
Work that is still in progress on this screenNbInlineLoading or NbSpinnerProgress belongs next to the thing making progress (Status indicators)
A per-row or per-item result in a long listThe row itselfTen toasts for ten rows is a wall. Say "3 of 10 failed" once, and mark the rows
Anything with an error code, an id, or a list the user must keepAn inline banner, a details panel, or the notification centreA toast cannot be scrolled back to

Three more rules:

  • Never toast something the user can already see. A row that disappeared reported itself.
  • Never toast twice for one action. One message for the request and another for the response is two interruptions for one thing. Keep the handle from push() and update() it.
  • Do not raise a toast from behind a modal. Toasts stack above dialogs (--nb-zindex-toast resolves above --nb-zindex-modal), so a toast fired while a dialog is open covers the surface the user is actually reading. Report it inside the dialog, and toast the result after it closes.

Choosing the variant ​

The variant is not a colour choice. It sets the icon, the accent, the hidden severity word, the politeness of the announcement (error is assertive, everything else is polite) and, under NbToaster, how long the message lives. Severity and lifetime are one decision, which is why they are in one table. The durations are NB_TOAST_DURATIONS as it ships.

VariantIt saysDefault lifeReach for it whenIt is the wrong variant when
successThe thing you asked for is done4000The result is not visible on screen: "Draft saved", "Invitation sent"The result is visible. A row that appeared has already reported itself
infoSomething changed, and you do not have to do anything about it6000State moved without the user: "Connection restored", "Export queued"You are announcing something the user just did. That is success
warningIt worked, but not cleanly, or it is about to stop working8000The outcome was partial and momentary: "3 of 10 rows skipped", "Retrying on the backup"The condition is still true after the toast goes. See below
errorIt failed0Something the user cannot see failed: a background sync, an export, a fired requestThe failure belongs to a form or a page in front of them. That is an inline banner, at the failure

error is 0 on purpose: it never auto-dismisses, because "it failed" is the beginning of a task, not the end of one. A toast carrying a cta also gets 0 from the queue unless you pass a duration yourself, since an action that removes itself while it is being reached for is not an action.

When a warning should have been a banner ​

A warning toast is often a condition rather than a warning, and a condition on a surface with an eight-second lifetime has been told to the user exactly once, at random. One question separates them.

Is it still true after the toast disappears?

If yes, it is not a toast at all. "Your trial ends in three days", "this environment is not production", "two members are still awaiting approval" are all true for as long as the page is, so they belong in NbBanner variant="callout", which cannot be dismissed because dismissing it would not make it untrue. If the warning is about the form or the page in front of the user, it is variant="inline" on that page.

A warning toast is only correct for an outcome that is finished and imperfect: the import ran, three rows were skipped, and nothing about that is still happening. If the user has to go and fix those three rows, the sentence has an action in it, and When not to use applies: give it a surface with a lifetime.

When you would still use NbToast directly ​

Only when the thing on screen is not a toast: a message pinned inside a panel, a story or a visual test that needs one frozen toast, a custom host that already exists and cannot be replaced this week. A bare NbToast times itself, so it works standalone.

For anything that is genuinely a toast, use the host.

Writing one ​

The words are covered once, in Writing style. Three things are peculiar to a message that removes itself:

  • Past tense, no full stop: "Draft saved", not "Your draft has been saved.".
  • The title carries what went wrong and the message carries the recovery: toast.error('Could not reach the server', { title: 'Save failed' }).
  • The action is a verb from the shared register (Try again, Refresh, Undo), never OK, Done, Close or Dismiss. The close button is the exit; a second control that also means "go away" is a coin toss for anyone reading the stack through a screen reader.

Severity is in words, not only in colour ​

Every toast renders a visually hidden severity word before the title, because the icon is aria-hidden inside NbIcon and the accent colour says nothing to a screen reader. Without it, "Could not reach the server" arrives with no indication that it is an error, which is a WCAG 1.4.1 Use of Color failure. Override statusLabel per toast, or once per queue with createToastQueue({ statusLabels }).

One clock, or its own ​

Standalone, NbToast times itself and pauses under the pointer. That is the right behaviour for one toast and the wrong behaviour for three: pausing only the hovered one lets the two below it expire while they are being read.

Under NbToaster the toast is managed. The queue owns the clock, the whole region pauses together, and the toast draws the bar from duration, paused and cycle. There is one countdown implementation either way.

Announcement, under a host ​

NbToaster renders its toasts with role="none" and aria-live="off" and announces from a live region that was mounted long before the message existed. A live region and its first message inserted in the same tick is the most common reason a toast is never heard at all. The severity word stays inside the toast, so browse mode still reads it, but only one thing speaks.

Used standalone, NbToast keeps its own role="alert" default and announces itself.