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
Preset actions support accept and reject buttons with optional onClick handlers. Clicking either one dismisses the snackbar.
The accept button uses the snackbar color; reject uses the neutral dark color. Each action renders as a flat button by default — set variant to any Button variant to change it.
actionsPlacement
Use actionsPlacement to choose where actions render:
- bottom (default) — a row below the title and description.
- trailing — the accept action next to the close button. reject is ignored.
- right — a vertical column on the right edge. The close button is hidden unless you set closeButton explicitly.
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 |
|---|---|
| close(id) | Closes the entry with the given id. |
| closeAll() | Closes every open snackbar. |
| closeTop() | Closes the topmost entry. |
| isOpen(id) | Whether the entry is currently open. |
| open(options) | Opens a snackbar. Returns an entry id. |
| stackSize | Number of open snackbar entries. |
| update(id, patch) | Patches props on an open entry. |
open options
| Option | Type | Description |
|---|---|---|
| actions | { accept?, reject? } | Preset action buttons. |
| actionsPlacement | bottom \| trailing \| right | Where actions render. Defaults to bottom. |
| color | SnackbarColor | Semantic tint. |
| description | string | Body text. |
| onClose | () => void | Called when a dismiss starts. |
| onClosed | () => void | Called after the leave animation. |
| padding | SnackbarPadding | Content padding preset. |
| rounded | SnackbarRounded | Border radius of the snackbar panel. |
| title | string | Headline text. |
| transition | SnackbarTransition | Enter/leave animation. |
Action fields
Fields accepted by actions.accept and actions.reject.
| Field | Type | Description |
|---|---|---|
| button | Partial<ButtonProps> | Props merged into the default Button. Ignored when link is set. |
| className | string | Extra classes for the action control. |
| label | string | Action text. Actions without a label are not rendered. |
| link | Partial<LinkProps> | Renders a Link instead of a Button. |
| onClick | () => void | Called on click, before the snackbar closes. |
| variant | ButtonVariant | Button variant. Defaults to flat. Ignored when link is set. |