Toastr overview
NbToastrService
The NbToastrService
provides a capability to build toast notifications.
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
.
status
- coloring and icon of the toast.
Default is basic
.
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.
destroyByClick
- provides a capability to destroy toast by click.
Default is true.
preventDuplicates
- don't create new toast if it has the same title, message and status.
Default is false.
duplicatesBehaviour
- determines how to treat the toasts duplication.
Compare with the previous message previous
or with all visible messages all
.
limit
- the number of visible toasts in the toast container. The number of toasts is unlimited by default.
hasIcon
- if true then render toast icon.
icon
- you can pass icon class that will be applied into the toast.
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.
Need some help or found an issue?
Ask on Stack Overflow with tag `nebular` or post an issue on GitHub.