Info
Success
Warning
Error
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Info",
Message = "Message with title and close",
Variant = SnackbarVariant.Info,
Closable = true,
DurationMs = 5000
});Toast messages are used to inform users of system status, completed actions, errors, or other relevant events. They appear in the corner of the screen (typically top-right) and are designed to be non-intrusive, allowing users to continue their current task without interruption.
Each type of toast conveys a specific message through its style and context. The available options are info, success, warning, and error. Icons are always included to reinforce the message type.
Info
Success
Warning
Error
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Info",
Message = "Message with title and close",
Variant = SnackbarVariant.Info,
Closable = true,
DurationMs = 5000
});Toast messages can appear in a variety of formats depending on the context and user needs. They may include an optional heading to provide a clear title or summary, or appear without a heading for a more compact message. Toasts can also feature interactive elements, such as embedded links that allow users to take immediate action. Additionally, they may include or omit a close (dismiss) button based on their level of urgency, duration, or whether they include an auto-dismiss behavior.
Title + Close
No Title + Close
No Title, No Close
With Action Link
// With title and close button
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Info",
Message = "Message with title and close",
Variant = SnackbarVariant.Info,
Closable = true
});
// With action link
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Info",
Message = "Message with link",
Variant = SnackbarVariant.Info,
ActionLabel = "View details",
OnAction = () => Console.WriteLine("Link clicked")
});Success snackbars for positive feedback and confirmations.
Warning snackbars for cautionary messages.
Error snackbars for critical messages and failures.
Monitor and control snackbar queue state.
Visible Snackbars
0Max Concurrent
3Toast notifications are positioned based on the platform to ensure optimal visibility without interfering with core content or user interactions.
SnackbarService.Enqueue(new SnackbarOptions
{
Message = "Snackbar at TopEnd",
Variant = SnackbarVariant.Info,
Placement = SnackbarPlacement.TopEnd,
DurationMs = 3000
});Snackbars queue automatically when MaxConcurrent is reached.
Shows 5 snackbars (queued)
for (int i = 1; i <= 5; i++)
{
SnackbarService.Enqueue($"Snackbar #{i}", SnackbarVariant.Info);
}Assign a unique key to prevent duplicate toast messages.
First click shows snackbar
Same key - updates existing
SnackbarService.Enqueue(new SnackbarOptions
{
Message = $"Progress saved at {DateTime.Now:HH:mm:ss}",
Variant = SnackbarVariant.Success,
Key = "save-progress", // Prevents duplicates with same key
DurationMs = 3000
});How to set up and use Toast Messages in your application.
// Program.cs
builder.Services.AddFod();<FodProviders>
<Router AppAssembly="@typeof(App).Assembly">
...
</Router>
</FodProviders>@inject ISnackbarService SnackbarService
// Simple usage
SnackbarService.Enqueue("Operation successful", SnackbarVariant.Success);
// With title
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Success",
Message = "Message with title and close",
Variant = SnackbarVariant.Success,
Closable = true
});
// With action link
SnackbarService.Enqueue(new SnackbarOptions
{
Title = "Info",
Message = "Message with link",
Variant = SnackbarVariant.Info,
ActionLabel = "View details",
OnAction = () => Console.WriteLine("Link clicked")
});ISnackbarService methods and SnackbarOptions properties.