Skip to content

Toast ​

Use bo-toast for brief feedback that does not interrupt the current task. Use useToast with one or more bo-toast-viewport components when notifications originate from different parts of the application or need a shared queue.

Basic Usage ​

bo-toast is a single notification. Use v-model:open when rendering it directly; use useToast with a viewport for application notifications. The default duration is ten seconds, while duration="0" keeps a demonstration toast open until it is closed.

<bo-button @click="showBasicToast">Show toast</bo-button>
<bo-toast-viewport position="top-right" />

Title and Description ​

Use title for the short result and description for optional supporting detail. When the default slot is supplied, it replaces both generated text blocks.

Variants ​

The supported variants are default, primary, success, warning, and destructive. The semantic variants also provide a corresponding status icon.

Default
Primary
Success
Warning
Destructive
<bo-toast v-model:open="defaultToastOpen" title="Default" :duration="0" />
<bo-toast v-model:open="primaryToastOpen" variant="primary" title="Primary" :duration="0" />
<bo-toast v-model:open="successToastOpen" variant="success" title="Success" :duration="0" />
<bo-toast v-model:open="warningToastOpen" variant="warning" title="Warning" :duration="0" />
<bo-toast v-model:open="destructiveToastOpen" variant="destructive" title="Destructive" :duration="0" />

Toast Container and Positions ​

bo-toast-viewport is the container for queued notifications. It teleports a fixed, pointer-aware region to body, announces it as a polite live region, and filters queued toasts by position. The default position is top-right. Supported positions are top-left, top-center, top-right, bottom-left, bottom-center, and bottom-right.

Mount one viewport for each position that the application uses. A toast shown with useToast is rendered only by the viewport with the matching position.

<bo-button @click="showAt('top-left')">Top left</bo-button>
<bo-button @click="showAt('top-center')">Top center</bo-button>
<bo-button @click="showAt('top-right')">Top right</bo-button>
<bo-button @click="showAt('bottom-left')">Bottom left</bo-button>
<bo-button @click="showAt('bottom-center')">Bottom center</bo-button>
<bo-button @click="showAt('bottom-right')">Bottom right</bo-button>
 
<bo-toast-viewport position="top-left" />
<!-- Mount one viewport for each position your app uses. -->

Close and Dismiss ​

Toasts are closable by default. The close button updates open to false and emits close; set closable to false when an automatic duration or programmatic dismissal is the only close path. useToast().dismiss(id) removes one queued toast, while clear() removes all queued toasts.

The toast is open.
<bo-toast>
  v-model:open="open"
  title="Dismissible toast"
  description="Close it with the button or programmatically."
  :duration="0"
  @close="closeMessage = 'Toast closed'"
/>

Stacking and the useToast API ​

Each call to show appends a toast to the shared queue and returns its id. Viewports stack their matching toasts with a small overlap. Hover or focus the stack to unwrap it; the individual close buttons remain available in both states. Timers pause while the stack is hovered and resume when the pointer leaves, so a toast still closes automatically when its remaining duration expires.

<bo-button @click="addManagedToast">Add queued toast</bo-button>
<bo-button kind="outline" @click="dismissManagedToast">Dismiss last</bo-button>
<bo-button kind="outline" @click="clear">Clear all</bo-button>
   <bo-toast-viewport position="top-right" />

useToast is a shared composable. Call it in any component and mount the corresponding viewport once in the application shell.

Usage Guidance ​

  • Keep a toast short and useful; do not put required decisions in it.
  • Use success for completed work, warning for attention, and destructive for failed or dangerous outcomes.
  • Use a stable position per application region and avoid mounting duplicate viewports for the same position.
  • Give long-lived or persistent notifications an explicit close path.

API Reference ​

BoToast Props ​

PropTypeDefaultDescription
idstringAutogeneratedToast id.
dataTestIdstringAutogeneratedThe test id attribute.
openbooleantrueVisibility state used by v-model:open.
titlestring-Short notification title.
descriptionstring-Supporting notification text.
variantBoToastVariantdefaultdefault, primary, success, warning, or destructive.
durationnumber10000Auto-close delay in milliseconds; 0 disables it.
closablebooleantrueWhether to render a close button.
closeAriaLabelstringClose notificationAccessible close-button label.
roleHTMLAttributes['role']statusNotification accessibility role.

BoToast Events and Slots ​

NameTypeDescription
update:openbooleanEmitted when visibility changes.
close-Emitted after automatic or manual closing.
defaultslotReplaces generated title and description.

BoToastViewport Props and Slots ​

PropTypeDefaultDescription
positionBoToastPositiontop-rightQueue position rendered by this viewport.
labelstringNotificationsAccessible label for the live region.
defaultslot-Additional content inside the viewport.

ToastOptions ​

useToast().show accepts all BoToast options except id, dataTestId, and open, plus position.

FieldTypeDefaultDescription
titlestring-Short notification title.
descriptionstring-Supporting notification text.
variantBoToastVariantdefaultNotification style.
durationnumber10000Auto-dismiss delay in milliseconds.
closablebooleantrueWhether the rendered toast has a close button.
closeAriaLabelstringClose notificationAccessible close label.
roleHTMLAttributes['role']statusNotification role.
positionBoToastPositiontop-rightViewport that renders the toast.

useToast() ​

Method / valueTypeDescription
toastsReadonly<Ref<readonly ToastMessage[]>>Read-only shared queue.
show(options: ToastOptions) => stringAdds a toast and returns its generated id.
dismiss(id: string) => voidRemoves one queued toast by id.
clear() => voidRemoves every queued toast.

ToastMessage ​

FieldTypeDescription
idstringGenerated id returned by show.
Toast optionsToastOptionsOptions used to render the notification.

Released under the MIT License.