Class RadzenAlert
An alert/notification box component for displaying important messages with semantic colors and optional close functionality. RadzenAlert provides contextual feedback messages for Success, Info, Warning, Error, and other notification scenarios. Supports semantic styles (Info, Success, Warning, Danger) for contextual coloring, variants (Filled, Flat, Outlined, Text), automatic contextual icons or custom icons via Icon property, optional close button via AllowClose for dismissible alerts, sizes (ExtraSmall, Small, Medium, Large), and content via Title/Text properties or rich content via ChildContent. Automatically displays appropriate icons based on AlertStyle (checkmark for Success, warning triangle for Warning, etc.) unless ShowIcon is set to false or a custom Icon is provided.
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenAlert : RadzenComponentWithChildren, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Examples
Basic success alert:
<RadzenAlert AlertStyle="AlertStyle.Success" Title="Success!" Text="Operation completed successfully." />
Warning alert with custom content:
<RadzenAlert AlertStyle="AlertStyle.Warning" AllowClose="false" ShowIcon="true">
<strong>Warning:</strong> Your session will expire in 5 minutes.
</RadzenAlert>
Dismissible info alert:
@if (showAlert)
{
<RadzenAlert AlertStyle="AlertStyle.Info" Variant="Variant.Flat"
AllowClose="true" Close=@(() => showAlert = false)>
This is an informational message that can be dismissed.
</RadzenAlert>
}
Constructors
RadzenAlert()
An alert/notification box component for displaying important messages with semantic colors and optional close functionality. RadzenAlert provides contextual feedback messages for Success, Info, Warning, Error, and other notification scenarios. Supports semantic styles (Info, Success, Warning, Danger) for contextual coloring, variants (Filled, Flat, Outlined, Text), automatic contextual icons or custom icons via Icon property, optional close button via AllowClose for dismissible alerts, sizes (ExtraSmall, Small, Medium, Large), and content via Title/Text properties or rich content via ChildContent. Automatically displays appropriate icons based on AlertStyle (checkmark for Success, warning triangle for Warning, etc.) unless ShowIcon is set to false or a custom Icon is provided.
Declaration
public RadzenAlert()
Examples
Basic success alert:
<RadzenAlert AlertStyle="AlertStyle.Success" Title="Success!" Text="Operation completed successfully." />
Warning alert with custom content:
<RadzenAlert AlertStyle="AlertStyle.Warning" AllowClose="false" ShowIcon="true">
<strong>Warning:</strong> Your session will expire in 5 minutes.
</RadzenAlert>
Dismissible info alert:
@if (showAlert)
{
<RadzenAlert AlertStyle="AlertStyle.Info" Variant="Variant.Flat"
AllowClose="true" Close=@(() => showAlert = false)>
This is an informational message that can be dismissed.
</RadzenAlert>
}
Properties
AlertStyle
Gets or sets the semantic style/severity of the alert. Determines the color scheme and default icon: Info (blue), Success (green), Warning (orange), Danger (red), etc.
Declaration
[Parameter]
public AlertStyle AlertStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| AlertStyle | The alert style. Default is Base. |
AllowClose
Gets or sets whether the alert can be dismissed by showing a close button. When enabled, a small X button appears in the top-right corner allowing users to close the alert. Handle the Close event to perform actions when the alert is dismissed.
Declaration
[Parameter]
public bool AllowClose { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Close
Gets or sets the callback which is invoked when the alert is closed by the user.
Declaration
[Parameter]
public EventCallback Close { get; set; }
Property Value
| Type | Description |
|---|---|
| EventCallback |
Icon
Gets or sets a custom Material icon name to display instead of the default contextual icon. Overrides the automatic icon selection based on AlertStyle. Use Material Symbols icon names (e.g., "info", "warning", "check_circle").
Declaration
[Parameter]
public string Icon { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The custom Material icon name. |
IconColor
Gets or sets a custom color for the alert icon. Supports any valid CSS color value. If not set, the icon color matches the alert's semantic style.
Declaration
[Parameter]
public string IconColor { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The icon color as a CSS color value. |
Shade
Gets or sets the color intensity shade for the alert. Works in combination with AlertStyle to adjust the color darkness/lightness.
Declaration
[Parameter]
public Shade Shade { get; set; }
Property Value
| Type | Description |
|---|---|
| Shade | The color shade. Default is Default. |
ShowIcon
Gets or sets whether to display the contextual icon based on the AlertStyle. When true, shows an appropriate icon (checkmark for Success, info icon for Info, warning for Warning, etc.). Set to false to hide the icon, or provide a custom icon via the Icon property.
Declaration
[Parameter]
public bool ShowIcon { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Size
Gets or sets the size of the alert component. Controls the padding, font size, and icon size within the alert.
Declaration
[Parameter]
public AlertSize Size { get; set; }
Property Value
| Type | Description |
|---|---|
| AlertSize | The alert size. Default is Medium. |
Text
Gets or sets the body text of the alert. This appears below the title as the main alert message. Overridden by ChildContent if custom content is provided.
Declaration
[Parameter]
public string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The alert text content. |
Title
Gets or sets the title text displayed prominently at the top of the alert. Use this for the main alert heading, with additional details in Text or custom content via ChildContent.
Declaration
[Parameter]
public string Title { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The alert title. |
Variant
Gets or sets the design variant that controls the alert's visual appearance. Options include Filled (solid background), Flat (subtle background), Outlined (border only), and Text (minimal styling).
Declaration
[Parameter]
public Variant Variant { get; set; }
Property Value
| Type | Description |
|---|---|
| Variant | The alert variant. Default is Filled. |
VisibleChanged
Gets or sets the callback which is invoked when the alert is shown or hidden.
Declaration
[Parameter]
public EventCallback<bool> VisibleChanged { get; set; }
Property Value
| Type | Description |
|---|---|
| EventCallback<bool> |
Methods
BuildRenderTree(RenderTreeBuilder)
An alert/notification box component for displaying important messages with semantic colors and optional close functionality. RadzenAlert provides contextual feedback messages for Success, Info, Warning, Error, and other notification scenarios. Supports semantic styles (Info, Success, Warning, Danger) for contextual coloring, variants (Filled, Flat, Outlined, Text), automatic contextual icons or custom icons via Icon property, optional close button via AllowClose for dismissible alerts, sizes (ExtraSmall, Small, Medium, Large), and content via Title/Text properties or rich content via ChildContent. Automatically displays appropriate icons based on AlertStyle (checkmark for Success, warning triangle for Warning, etc.) unless ShowIcon is set to false or a custom Icon is provided.
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
| Type | Name | Description |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected override string GetComponentCssClass()
Returns
| Type | Description |
|---|---|
| string |
Overrides
OnInitialized()
Called by the Blazor runtime.
Declaration
protected override void OnInitialized()
Overrides
SetParametersAsync(ParameterView)
Called by the Blazor runtime when parameters are set.
Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| ParameterView | parameters | The parameters. |
Returns
| Type | Description |
|---|---|
| Task |