Back to components

Toast

zyra-toast-container

Transient notifications for confirmations, warnings, and system messages without interrupting the flow.

Component preview

Explore the available states and the real library behavior for this component.

zyra-toast Playground

successerrorwarninginfo

Toast notification service - call from anywhere, auto-dismiss, persistent support

Controls
variant
title
description
persistent
duration (ms)
Service API

toastService.success(title, opts?)

toastService.error(title, opts?)

toastService.warning(title, opts?)

toastService.info(title, opts?)

toastService.dismiss(id)

toastService.dismissAll()

opts: description, duration (0 = persistent)

Live Preview - toasts appear bottom-right success4s
Operation completedYour changes have been saved.
Generated Code
import { inject } from '@angular/core';
import { ZyraToastService } from 'zyra-ng-ui';

const toastService = inject(ZyraToastService);

toastService.success('Operation completed', {
  description: 'Your changes have been saved.',
  duration: 4000,
});

// Place this once in your app template
<zyra-toast-container />
All Variants click to fire each
success
Saved successfully!
fire
error
Something went wrong
fire
warning
Session expiring soon
fire
info
New update available
fire
Real World Scenarios click to demo
Form saved
After a successful form submit
Network error
API call fails, shows for 6s
Session warning
Auth token expiring, shows for 8s
New message
Real-time notification event
Multiple in sequence
Upload -> processing -> done
Persistent toast
duration: 0 - stays until dismissed

Copy-paste example

Drop this into your Angular standalone component and it works out of the box.

toast.demo.ts
import { Component, inject } from '@angular/core';
import {
  ZyraButton,
  ZyraToastContainer,
  ZyraToastService,
} from 'zyra-ng-ui';

@Component({
  selector: 'app-demo-toast',
  standalone: true,
  imports: [ZyraButton, ZyraToastContainer],
  template: `
    <zyra-button variant="primary" (clicked)="showSavedToast()">
      Show success toast
    </zyra-button>

    <zyra-toast-container />
  `,
})
export class DemoToastComponent {
  private readonly toast = inject(ZyraToastService);

  showSavedToast(): void {
    this.toast.success('Saved successfully', {
      description: 'Your profile changes are now live.',
    });
  }
}

Variants

All the visual modes and states available for this component.

success

Confirms a completed action (green)

info

Neutral informational message (blue)

warning

Cautionary notice that may need attention (amber)

error

Failed action or critical issue (red)

API

All inputs and configuration options for zyra-toast-container.

PropTypeDefaultDescription
toast.success()(title, options?) => void-Show a success toast via ZyraToastService
toast.info()(title, options?) => void-Show an info toast
toast.warning()(title, options?) => void-Show a warning toast
toast.error()(title, options?) => void-Show an error toast
options.descriptionstring-Secondary body text below the title
options.durationnumber4000Auto-dismiss delay in milliseconds

Accessibility

Built to meet WCAG 2.0 AA. These notes cover the key ARIA, keyboard, and interaction behaviours.

  • Toast container uses role="region" with an aria-label for screen reader announcement
  • Success/info toasts use aria-live="polite"; error toasts use aria-live="assertive"
  • Each toast includes a visible dismiss button with an accessible label
  • Toasts do not auto-dismiss during keyboard navigation to prevent losing context