Free
Pro

Toast / Snackbar

Base UI (Angular) toasts are imperative status messages via ToastService — inject it, call success or show. Multiple toasts stack like a deck; hover or focus expands the stack, swipe dismisses, and hover pauses the timer. prefers-reduced-motion falls back to a static list. The host live region is created on first use; do not put base-toast-container in templates. The service skips DOM work on the server so prerender stays clean.

When to use

  • Save, copy, undo, and promise-loading feedback that should not steal focus.
  • Several notices at once that should stack instead of covering the page.

When not to use

  • Errors that must be read and acted on — use an alert, dialog, or inline field error.
  • Persistent banners (cookies, outages) — use cookie-banner or a page alert.

Install with npx base-ui-cli add toast.

free

Playground

Playground

Color
Position

HTML

this.toast.show('File deleted', {
  color: 'success',
  position: 'top-right',
  action: { label: 'Undo', onClick: () => restore() },
});

Stacked toasts

Fire a few in a row. Newer toasts sit in front; older ones peek behind. Hover or Tab into the stack to expand it. Drag a toast toward the nearest edge to dismiss. Hovering pauses the auto-dismiss timer. prefers-reduced-motion: reduce renders a static list instead. 15-second walkthrough: stacked toasts in Angular 22.

Toast Colors


Convenience Methods

The ToastService provides shortcut methods: success(), error(), warning(), and info().

Configuration

Each toast can be configured with color, duration, icon, and position. See the API reference below.

Actions and promises

Pass action for an inline button, or use promise() for loading → success/error.

Keyboard & accessibility

Role
Informational toasts use role=status. Danger and warning use role=alert. The host is an aria-live region. Overflow cards behind the stack are inert until the stack expands.
Focus
Toasts do not steal focus. Tabbing into a toast expands the stack. Action and dismiss buttons are reachable if the toast is still visible. Hover or focus pauses auto-dismiss.

Shortcuts

  • TabReach the action or dismiss button on a visible toast — focus expands the stack
  • SwipeDrag a toast toward the nearest edge to dismiss (disabled when reduced motion is on)

Site-wide VPAT-style notes live on the accessibility report.

FAQ

Same wording as the canonical FAQ.

Yes. Toast is free: inject ToastService and call success, error, or show. Multiple toasts stack like a deck; hover or focus expands the stack; swipe dismisses; hover pauses auto-dismiss. prefers-reduced-motion falls back to a static list. Install with npx base-ui-cli add toast. Do not place base-toast-container in templates.

Base UI (Angular) at base-ui.net ships a copy-in ToastService with stacked expandable toasts, swipe-to-dismiss, and a reduced-motion static list. It is not the React Sonner package. Install with npx base-ui-cli add toast.

Yes. The docs site prerenders every catalog route to static HTML, and a blocking CI job fails the build if any route stops rendering.

Installation

Run the following command to add this component to your project:

bash

npx base-ui-cli add toast

API Reference

For AI agents

Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.

bash

npx -y base-ui-ng-mcp

Base UI provides standalone components. Import the exact elements you want to use into your component.

typescript (Example)

// Install: npx base-ui-cli add toast
// Paths are relative to aliases.components (default: src/app/components)
import { ToastConfig, ToastPromiseMessages, ToastService } from './toast/toast.service';

@Component({
  selector: 'app-your-component',
  template: `...`
})
export class YourComponent {
  private toast = inject(ToastService);
}

API for toast — generated from JSDoc in the library source.

API reference for toast
APIMemberTypeDescription
ToastServiceshow()(message: string, config: ToastConfig = {}) => numberShows a toast and returns its id.
ToastServicedismiss()(id: number) => voidDismisses a toast by id.
ToastServicesuccess()(message: string, config?: ToastConfig) => numberSuccess toast.
ToastServiceerror()(message: string, config?: ToastConfig) => numberError toast.
ToastServicewarning()(message: string, config?: ToastConfig) => numberWarning toast.
ToastServiceinfo()(message: string, config?: ToastConfig) => numberInfo toast.
ToastServicepromise()(promiseOrFn: Promise<T> | (() => Promise<T>), messages: ToastPromiseMessages<T>, config?: ToastConfig) => Promise<T>Loading toast that resolves to success or error when the promise settles.
ToastServiceclearAll()() => voidDismisses every visible toast.
ToastConfigcolorToastColorSemantic color of the toast. Defaults to `primary`.
ToastConfigdurationnumberAuto-dismiss delay in ms. `0` keeps the toast until dismissed. Defaults to 4000.
ToastConfigiconstring`base-icon` name. Defaults from `color` when omitted.
ToastConfigpositionToastPositionViewport corner. Defaults to `top-right`.
ToastConfigactionToastActionOptional inline button (e.g. Undo). `{ label, onClick, dismiss? }`.
ToastPromiseMessagesloadingstringShown while the promise is pending (`duration: 0`).
ToastPromiseMessagessuccessstring | ((data: T) => string)Shown on resolve.
ToastPromiseMessageserrorstring | ((err: unknown) => string)Shown on reject.