Toast
Toasts, referred to as “notifications” in the UI, are pop-up notifications that keep users informed by briefly:
- Confirming an action they took.
- Informing them about a timely event.
- Communicating the status of a process initiated.
The information in a toast is useful and relevant but never critical.
Examples
Default Toast
Click on this button to open a Toast. The toast is created by just specifying an intent and a message.
Toast with options
Click on this button to open a Toast. The toast is created by specifying an intent, message, action and a random timeout between 3 and 15 seconds.
Confirmation Toasts
Communication Toasts
Progress Toasts
Custom component
Remove toasts
ToastManager.Clear...()
methods. By default,
toasts are removed from the queue as well. To keep toasts in the queue, pass false
for the includeQueue
parameter.
Remove queued toasts
ToastProvider
IMPORTANT!!
Toasts are rendered through the <FluentToastProvider />
component. This component needs to be added to the main layout of your application/site.
You typically do this in the MainLayout.razor
file at the end of the <main>
section like shown below.
For the Toasts to work properly, the <FluentToastProvider/>
needs interactivity! If you are using "per page" interactivity, make sure to add a @rendermode
to
either the provider itself or the component the provider is placed in.
<main>
<nav>
:
</nav>
<div class="content">
<article id="article">
@Body
</article>
</div>
<FluentToastProvider MaxToastCount="10" />
</main>
See the documentation below for more information about the FluentToastProvider
parameters.
Documentation
FluentToastProvider Class
Parameters
Name | Type | Default | Description |
---|---|---|---|
MaxToastCount | int | 4 | Gets or sets the maximum number of toasts that can be shown at once. Default is 4. |
Position | ToastPosition | TopRight | Gets or sets the position on screen where the toasts are shown. See ToastPosition Default is ToastPosition.TopRight |
RemoveToastsOnNavigation | bool | True | Gets or sets whether to remove toasts when the user navigates to a new page. Default is true. |
ShowCloseButton | bool | True | Gets or sets whether to show a close button on a toast. Default is true. [Obsolete('This parameter will be removed in a future version. It is and should not not used.')] |
Timeout | int | 7000 | Gets or sets the number of milliseconds a toast remains visible. Default is 7000 (7 seconds). |
Methods
Name | Parameters | Type | Description |
---|---|---|---|
RemoveToast | string toastId | void |
FluentToast Class
Parameters
Name | Type | Default | Description |
---|---|---|---|
Instance | ToastInstance | Gets or sets the instance containing the programmatic API for the toast. |
Methods
Name | Parameters | Type | Description |
---|---|---|---|
Close | void | Closes the toast | |
HandlePrimaryActionClick | void | ||
HandleSecondaryActionClick | void | ||
HandleTopActionClick | void | ||
PauseTimeout | void | ||
ResumeTimeout | void |