Base UI (Angular) toasts are imperative status messages via ToastService — inject it, call success or show. 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.
Install with npx base-ui-cli add toast.
Playground
this.toast.show('File deleted', {
color: 'success',
position: 'top-right',
action: { label: 'Undo', onClick: () => restore() },
}); The ToastService provides shortcut methods: success(), error(), warning(), and info().
Each toast can be configured with color, duration, icon, and position. See the API reference below.
Pass action for an inline button, or use promise() for loading → success/error.
Site-wide VPAT-style notes live on the accessibility report.
Run the following command to add this component to your project:
npx base-ui-cli add toast
For AI agents
Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.
npx -y base-ui-mcp
Base UI provides standalone components. Import the exact elements you want to use into your component.
// 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 | Member | Type | Description |
|---|---|---|---|
ToastService | show() | (message: string, config: ToastConfig = {}) => number | Shows a toast and returns its id. |
ToastService | dismiss() | (id: number) => void | Dismisses a toast by id. |
ToastService | success() | (message: string, config?: ToastConfig) => number | Success toast. |
ToastService | error() | (message: string, config?: ToastConfig) => number | Error toast. |
ToastService | warning() | (message: string, config?: ToastConfig) => number | Warning toast. |
ToastService | info() | (message: string, config?: ToastConfig) => number | Info toast. |
ToastService | promise() | (promiseOrFn: Promise<T> | (() => Promise<T>), messages: ToastPromiseMessages<T>, config?: ToastConfig) => Promise<T> | Loading toast that resolves to success or error when the promise settles. |
ToastService | clearAll() | () => void | Dismisses every visible toast. |
ToastConfig | color | ToastColor | Semantic color of the toast. Defaults to `primary`. |
ToastConfig | duration | number | Auto-dismiss delay in ms. `0` keeps the toast until dismissed. Defaults to 4000. |
ToastConfig | icon | string | `base-icon` name. Defaults from `color` when omitted. |
ToastConfig | position | ToastPosition | Viewport corner. Defaults to `top-right`. |
ToastConfig | action | ToastAction | Optional inline button (e.g. Undo). `{ label, onClick, dismiss? }`. |
ToastPromiseMessages | loading | string | Shown while the promise is pending (`duration: 0`). |
ToastPromiseMessages | success | string | ((data: T) => string) | Shown on resolve. |
ToastPromiseMessages | error | string | ((err: unknown) => string) | Shown on reject. |
Content