Imperative snackbar API for toast notifications from anywhere in the app.
Introduction
useSnackbarAction opens toast notifications imperatively. Call open() with title, description, and optional actions instead of declaring <Snackbar> in your template.
Stack position, max visible count, and default timeout are configured on BridgeSnackbarHost via BridgeUIHosts.
Use the framework selector in the site header to switch between React and Vue.
Import
import { BridgeUIHosts } from "@bridge-ui/vue/Actions";
import { useSnackbarAction } from "@bridge-ui/vue/Actions";import { BridgeUIHosts } from "@bridge-ui/react/Actions";
import { useSnackbarAction } from "@bridge-ui/react/Actions";Setup
Mount BridgeUIHosts with the snackbar host inside BridgeUIProvider or snackbars will not appear.
Configure host defaults on BridgeUIHosts inside BridgeUIProvider:
<BridgeUIHosts :snackbar="{ max: 3, timeout: 5000, position: 'bottom-center' }">
<!-- routes / pages -->
</BridgeUIHosts><BridgeUIHosts snackbar={{ max: 3, timeout: 5000, position: "bottom-center" }}>
{children}
</BridgeUIHosts>Basic usage
Options
Override per-entry color, padding, rounded, and transition on open().
Actions
Footer actions support accept and reject buttons with optional onClick handlers.
rightButtons
Set rightButtons: true to render actions in a vertical column on the right side of the snackbar.
close / closeTop / closeAll / stack
Snackbars stack up to the host max. Use close(id), closeTop(), or closeAll() to dismiss programmatically.
Callbacks
onClose and onClosed fire when a snackbar is dismissed by the user, timer, or imperative API.
update
Patch an open snackbar with update(id, { props }) to change title, color, or actions without reopening.
API
| Method / property | Description |
|---|---|
| open(options) | Opens a snackbar. Returns an entry id. |
| close(id) | Closes the entry with the given id. |
| closeTop() | Closes the topmost entry. |
| closeAll() | Closes every open snackbar. |
| update(id, patch) | Patches props on an open entry. |
| isOpen(id) | Whether the entry is currently open. |
| stackSize | Number of open snackbar entries. |
open options
| Option | Type | Description |
|---|---|---|
| title | string | Headline text. |
| description | string | Body text. |
| color | SnackbarColor | Semantic tint. |
| padding | SnackbarPadding | Content padding preset. |
| rounded | SnackbarRounded | Border radius of the snackbar panel. |
| transition | SnackbarTransition | Enter/leave animation. |
| actions | { accept?, reject? } | Footer action buttons. |
| rightButtons | boolean | Render actions in a vertical column on the right. |
| onClose | () => void | Called when a dismiss starts. |
| onClosed | () => void | Called after the leave animation. |