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

Example

Click on this button to open a Toast. The toast is created by just specifying an intent and a message.

Open
Download: 

Toast with options

Example

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.

Open
Download: 

Confirmation Toasts

Example
Show Success Show Warning Show Error Show Info Show progress Show upload Show download Show event Show mention Show custom
Without icon With action Custom timeout Long Success
Download: 

Communication Toasts

Example
Communication toast example 1 Communication toast example 2
Download: 

Progress Toasts

Example
Progress toast example 1 Update Reset Close Indeterminate progress toast
Download: 

Custom component

Example
Custom Toast with parameters
Download: 

Remove toasts

Toasts can be removed by calling 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.
Example
Clear all Clear all, preserve queue Clear specific intent Clear success Clear warning Clear error Clear info Clear progress Clear upload Clear download Clear event Clear avatar Clear custom

Remove queued toasts

Example
Clear all Clear specific intent Clear success Clear warning Clear error Clear info Clear progress Clear upload Clear download Clear event Clear avatar Clear custom

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
MaxToastCountint
4
Gets or sets the maximum number of toasts that can be shown at once. Default is 4.
PositionToastPosition
TopRight
Gets or sets the position on screen where the toasts are shown. See ToastPosition
Default is ToastPosition.TopRight
RemoveToastsOnNavigationbool
True
Gets or sets whether to remove toasts when the user navigates to a new page. Default is true.
ShowCloseButtonbool
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.')]
Timeoutint
7000
Gets or sets the number of milliseconds a toast remains visible. Default is 7000 (7 seconds).

Methods

Name
Parameters
Type
Description
RemoveToaststring toastId
void

FluentToast Class

Parameters

Name
Type
Default
Description
InstanceToastInstance
Gets or sets the instance containing the programmatic API for the toast.

Methods

Name
Parameters
Type
Description
Closevoid
Closes the toast
HandlePrimaryActionClickvoid
HandleSecondaryActionClickvoid
HandleTopActionClickvoid
PauseTimeoutvoid
ResumeTimeoutvoid
BottomLeft
BottomStart
BottomCenter
BottomRight
BottomEnd
TopLeft
TopStart
TopCenter
TopRight
TopEnd
An error has occurred. This application may no longer respond until reloaded. Reload 🗙