Represents an instance of a Toast
It handles the user interactions and orchestrates the state transitions
Name | Type | Description |
---|---|---|
Icon | String | |
Message | String | |
Options | MatToastOptions | |
Title | String |
Toasts provide brief notifications or messages about app processes
Name | Type | Description |
---|---|---|
Attributes | Dictionary<String,Object> | Gets or sets a collection of additional attributes that will be applied to the created element. |
Class | String | Specifies one or more classnames for an DOM element. |
Id | String | |
RefBack | ForwardRef | |
Style | String | Specifies an inline style for an DOM element. |
Ref | ElementReference | Returned ElementRef reference for DOM element. |
Add using MatBlazor; and then in the ConfiguresServices method include services.AddMatToaster...
using MatBlazor;
services.AddMatToaster(config =>
{
config.Position = MatToastPosition.BottomRight;
config.PreventDuplicates = true;
config.NewestOnTop = true;
config.ShowCloseButton = true;
config.MaximumOpacity = 95;
config.VisibleStateDuration = 3000;
});
The toast container must be added to the App.razor component or to another component always loaded in the application like MainLayout.razor. It is important to have exactly one instance of this component rendered in the application tree at any given time.
<MatToastContainer />
In a component:
@inject IMatToaster Toaster
In a class:
[Inject]
protected IMatToaster Toaster { get; set; }
Then call the display method:
Toaster.Add("Toast body text","Toast title", "code");