Services
TwToastProvider
TwToast is a Blazor toast notification service. Call ITwToastService.Show with a message, title, Color and icon, with duration, persistence and custom toasts.
Last updated
Setup
TwToastProvider component to your app and inject the ITwToastService.
1. Add TwToastProvider to your layout
Place the <TwToastProvider /> component in your main layout file (e.g., MainLayout.razor or App.razor):
<TwToastProvider />2. Register the services
The toast service is registered automatically when you call AddTwBlazor() with your configured theme
(see Get Started for the full theme setup):
builder.Services.AddTwBlazor(_ => { }, Theme.CreateDefaultTheme);3. Inject the service in your component
@inject ITwToastService ToastServiceToast Types
Custom Toasts
Show() method, or build a ToastModel directly for full control.
Duration & Persistence
0 to make it persistent until manually dismissed.
Managing Toasts
ClearAll() method.
Theme Configuration
TwBlazorTheme.Components (a TwToastTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
ToastRounded |
Rounded? | |
Container |
string | |
Toast |
string | |
HeaderClasses |
string | |
Title |
string | |
Message |
string | |
Timestamp |
string | |
IconContainer |
string | |
CloseButton |
string | |
ToastWidth |
string |
Global Theme Configuration
These reuse shared design tokens configured once on TwBlazorTheme, rather than being unique to this component.
| Property | Type | Controls |
|---|---|---|
Colors |
TwBlazorPalette |
For example, to move toasts to the top-right and make them fully rounded:
Duration isn't themed - it's passed per call via Show(..., duration) or
ToastModel.Duration (default 5000ms, 0 = persistent).
See the Theme page for the full colour and design-token reference.
Full reference: TwToastTheme on the API docs.