Toastr overview

Overview
API
Theme
Examples

NbToastrService

The NbToastrService provides a capability to build toast notifications.

Showcase

NbToastrService.show(message, title, config) accepts three params, title and config are optional.

Installation

Import NbToastrModule.forRoot() to your app module.

@NgModule({
  imports: [
    // ...
    NbToastrModule.forRoot(config),
  ],
})
export class AppModule { }

Usage

Calling NbToastrService.show(...) will render new toast and return NbToastrRef with help of which you may close newly created toast by calling close method.

const toastRef: NbToastRef = this.toastrService.show(...);
toastRef.close();

Config accepts following options:

position - determines where on the screen toast will be rendered. Default is top-end.

Position

status - coloring and icon of the toast. Default is basic.

Status

duration - the time after which the toast will be destroyed. 0 means endless toast, that may be destroyed by click only. Default is 3000 ms.

Duration

destroyByClick - provides a capability to destroy toast by click. Default is true.

Destroy by click

preventDuplicates - don't create new toast if it has the same title, message and status. Default is false.

Prevent duplicates

duplicatesBehaviour - determines how to treat the toasts duplication. Compare with the previous message previous or with all visible messages all.

Prevent duplicates behaviour

limit - the number of visible toasts in the toast container. The number of toasts is unlimited by default.

Prevent duplicates behaviour

hasIcon - if true then render toast icon. icon - you can pass icon class that will be applied into the toast.

Has icon

NbToastComponent

The NbToastComponent is responsible for rendering each toast with appropriate styles.

NbToastrConfig

The NbToastrConfig class describes configuration of the NbToastrService.show and global toastr configuration.

Dialog
Previous page
Tooltip
Next page

Need some help or found an issue?

Ask on Stack Overflow with tag `nebular` or post an issue on GitHub.