Toasts
Angular Bootstrap 5 Toast component
Responsive Toast built with Bootstrap 5, Angular and Material Design. Non-disruptive notification message in the corner of the interface. It provides quick 'at-a-glance' feedback on the outcome of an action.
Push notifications to your visitors with a 'toast', a lightweight and easily customizable toast message. Toasts are designed to mimic the push notifications that have been popularized by mobile and desktop operating systems.
Note: Read the API tab to find all available options and advanced customization
Basic example
Click the buttons to launch the toasts.
You can create toast dynamically from any component using a built-in service. To achieve this, follow these steps:
1. Create a new component with Angular CLI and add some HTML code to the template.
ng generate component toast
2. Inject MdbNotificationService
to the component from which you want to open the
toast and use the open
method.
Inject and receive data
You can inject data to the toast by passing it to the data
parameter in the toast
options.
Here is an example showing how to use injected data in the toast component:
Receive data from the toast
You can receive data from the toast to use it in other components:
Here is an example showing how to use data received from toast in other components:
Static example
Colors
Create different toast color schemes with our color and background utilities.
Placement
You can set position of every notification using
data-mdb-position
attribute or update()
method.
Select horizontal / vertical alignment
Current position: top-right
Offset
You can also change offset of every notification using
offset
option.
Stacking
You can turn on/off stacking your notifications using
stacking
option.
Toasts - API
Import
Options
Name | Type | Default | Description |
---|---|---|---|
position
|
string | 'top-right' |
Sets a position for the toast - top-left | top-right | bottom-left | bottom-right |
delay |
number | 5000 |
Sets the length of animation delay |
autohide
|
boolean | false |
Toast will hide automatically or not |
width
|
string | 'unset' |
Sets width of toast |
offset |
number | 10 |
Defines offset of the element |
stacking
|
boolean | false |
Enables stacking toasts |
Methods
MdbNotificationService
Name | Description |
---|---|
open |
Opens toast |
MdbNotificationRef
Method | Description |
---|---|
onClose: Observable<any> |
Returns observable on toast close. |
CSS variables
As part of MDB’s evolving CSS variables approach, toast now use local CSS variables on
.toast
for enhanced real-time customization. Values for the CSS variables are set
via Sass, so Sass customization is still supported, too.