Toast

A succinct message that is displayed temporarily.

PreviousNext

Installation

1

Run the CLI

Use the CLI to add the component to your project.

npx @ngzard/ui@latest add toast
2

Register toast to your project

app.component.ts'
app.component.ts'
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { ZardToastComponent } from '@/shared/components/toast/toast.component';
 
@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, ZardToastComponent],
  template: `
    <router-outlet></router-outlet>
    <z-toaster />
  `,
})
export class AppComponent {}

Examples

default

destructive

success

loading

advanced

position

Top LeftTop CenterTop RightBottom LeftBottom CenterBottom Right

API

[z-toaster] Component

z-toaster is a component that displays toast notifications. It uses ngx-sonner under the hood.

To customize the toaster, pass the following props to the component.

Property Description Type Default
[variant] Toast variant styling default | destructive default
[theme] Theme for the toasts light | dark | system system
[position] Position of the toast container top-left | top-center | top-right | bottom-left | bottom-center | bottom-right bottom-right
[richColors] Enable rich colors boolean false
[expand] Expand toasts by default boolean false
[duration] Auto-dismiss duration (ms) number 4000
[visibleToasts] Maximum visible toasts number 3
[closeButton] Show close button boolean false