AstrolUI AstrolUI
Yellow Orange Red Green Blue Purple Custom color
Light mode
Notification

1. Minimum notifications

Note
In this example, buttons are implemented, so it is recommended to refer to their documentation.
@using Astrol.Entities.Basic.Static.Notification
@using Astrol.Component.Basic.Button
@using Astrol.Entities.Basic.UI
@using Astrol.JSInterop.Base
@inject AstrolJSInterop jsI
 
<AstrolButton OnClick="x=>ShowMinimalNotification()"
              Style="AstrolStyle.Blue"
              Text="Click me" />
@code {
   private async Task ShowMinimalNotification() {
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: Base".NotificationBase());
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: None".NotificationNone());
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: Info".NotificationInfo());
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: Error".NotificationError());
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: Warning".NotificationWarning());
       await Task.Delay(400);
       await jsI.Notification("Minimum notification: Success".NotificationSuccess());
   }
}

2. Custom notifications


@using Astrol.Component.Basic.Button
@using Astrol.Entities.Basic.UI
@using Astrol.JSInterop.Base
@inject AstrolJSInterop jsI
 
<AstrolButton OnClick='x => ShowNotification("Hello World!", "astrol-ok", AstrolStyle.Blue)'
              Style='AstrolStyle.Blue'
              Text='Click me' />
@code {
   private async Task ShowNotification(string message,string icon, AstrolStyle type, bool outline = false) {
       await jsI.Notification(new Notification
       {
           Type = type,
           Icon = icon,
           Message = message,
           Outline = outline,
       });
   }
}

3. IAstrolToast / IAstrolModal

Note
Recommended way: the IAstrolToast and IAstrolModal services are injected into any component, need no @ref and are rendered by Blazor.

// Program.cs
using Astrol.Component.Basic;
builder.Services.AddAstrolBasic();
@using Astrol.Component.Basic.Toast
@using Astrol.Component.Basic.Modal
@inject IAstrolToast Toast
@inject IAstrolModal Modal
@* AstrolLayoutMenu already includes <AstrolToastHost /> and <AstrolModalHost /> *@
@code {
   private void Save() {
       Toast.Success("Saved");
       Toast.Error("Could not save\nPlease try again");
   }
   private async Task Delete() {
       if (await Modal.ConfirmAsync("Are you sure?", "The item will be deleted."))
           Toast.Success("Deleted");
   }
   private async Task Edit() {
       // EditUser: your component; it closes itself with [CascadingParameter] AstrolModalReference
       var result = await Modal.ShowAsync<EditUser>("Edit", new Dictionary<string, object?> { ["Id"] = 5 });
       if (!result.Cancelled) { var user = result.GetData<User>(); }
   }
}

Supported parameters

IAstrolToast service (recommended): @inject IAstrolToast Toast and Toast.Success / Error / Warning / Info("message", seconds) (default 5 / 8 / 6 / 5 seconds), Toast.Show("message", style, icon, seconds, outline), Toast.Show(notification) with the model below, or Toast.Clear(). It is rendered by Blazor, pauses on hover, can be closed with the keyboard, follows the theme and stays above modals. Requires AddAstrolBasic(); AstrolLayoutMenu already includes the host (without it, add <AstrolToastHost /> once, e.g. in MainLayout; with no host the JS notification is used).

String extensions (@using Astrol.Entities.Basic.Static.Notification), for jsI.Notification(...) or Toast.Show(...): "text".NotificationSuccess(), NotificationError, NotificationWarning, NotificationInfo, NotificationNone and NotificationBase, with optional parameters (icon = "astrol-warning", outline = true, time = 5, allowHtml = false).

Notification model (also for jsI.Notification(...)):

  • Message (string), text to display. Line breaks \n are kept.
  • AllowHtml (bool), renders the message as HTML. Default false (plain text, prevents HTML injection); use it only with trusted content.
  • Icon (string), icon (default astrol-warning ).
  • ShowLoad (bool), lifetime bar (default true).
  • Outline (bool), style without fill (default false; true in the extensions).
  • Time (int), seconds visible (default 5); with IAstrolToast, 0 = stays until closed (with jsI.Notification it closes immediately).
  • Type (AstrolStyle), color: Base, White, Black, Red, Orange, Green, Blue, Yellow, Purple.
Markdown for AI © 2026 AstrolUI v10.0.13