<FodAlert Color="AlertColor.Info">
This is a basic informational alert message.
</FodAlert>Alert
Alerts are persistent notifications that inform users of important information, warnings, errors, or success states. They support dismissibility, custom icons, action buttons, and accessibility features.
Quick Start
Basic alert usage with default settings.
Colors
Alerts support four semantic colors: Info, Success, Warning, and Error. Each color conveys a specific message type.
Info
Success
Warning
Error
<FodAlert Color="AlertColor.Info">Info message</FodAlert>
<FodAlert Color="AlertColor.Success">Success message</FodAlert>
<FodAlert Color="AlertColor.Warning">Warning message</FodAlert>
<FodAlert Color="AlertColor.Error">Error message</FodAlert>Variants
Alerts come in three visual variants: Standard (subtle background), Filled (solid background), and Outlined (bordered).
Standard (Default)
Filled
Outlined
All Colors in Filled Variant
<FodAlert Color="AlertColor.Info" Variant="AlertVariant.Standard">
Standard variant
</FodAlert>
<FodAlert Color="AlertColor.Info" Variant="AlertVariant.Filled">
Filled variant
</FodAlert>
<FodAlert Color="AlertColor.Info" Variant="AlertVariant.Outlined">
Outlined variant
</FodAlert>With Title
Alerts can include a title for additional context. Use Title for simple text or TitleContent for rich content.
With Title
Information
Success with Title
Operation Complete
Warning with Title
Attention Required
Error with Title
Error Occurred
<FodAlert Color="AlertColor.Info" Title="Information">
This alert includes a title to provide additional context.
</FodAlert>
<FodAlert Color="AlertColor.Success" Title="Operation Complete">
All files have been uploaded successfully.
</FodAlert>Custom Icons
Override the default icon or hide it entirely using the Icon and HideIcon parameters.
Default Icon (automatic)
Custom Icon
Hidden Icon
<FodAlert Color="AlertColor.Info">
<Icon>
<FodIcon Icon="IconName.Settings"/>
</Icon>
<ChildContent>
This alert uses a custom settings icon.
</ChildContent>
</FodAlert>
<FodAlert Color="AlertColor.Info" HideIcon="true">
This alert has no icon displayed.
</FodAlert>With Actions
Add action buttons to alerts using the Action render fragment.
Single Action
Connection Failed
Multiple Actions
Unsaved Changes
<FodAlert Color="AlertColor.Error" Title="Connection Failed">
<ChildContent>
Unable to establish a connection to the server.
</ChildContent>
<Action>
<FodButton Type="FodColor.Destructive" Size="Size.Small"
Variant="ButtonVariant.Text" OnClick="HandleRetry">
Retry
</FodButton>
</Action>
</FodAlert>Dismissible
Enable the close button with Dismissible parameter. Use OnDismiss callback to react to dismissal.
Dismissible Info
Dismissible Success
File Uploaded
Dismissible Warning
Low Storage
Dismissible Error
<FodAlert Color="AlertColor.Info" Dismissible="true" OnDismiss="HandleDismiss">
Click the close button to dismiss this alert.
</FodAlert>
@code {
private void HandleDismiss()
{
Console.WriteLine("Alert was dismissed");
}
}Controlled Visibility
Use Visible parameter with two-way binding to control alert visibility programmatically.
Controls
Current State: Visible
Controlled Alert
<FodButton OnClick="@(() => showAlert = true)">Show Alert</FodButton>
<FodButton OnClick="@(() => showAlert = false)">Hide Alert</FodButton>
<FodAlert Color="AlertColor.Info"
Dismissible="true"
@bind-Visible="showAlert">
This alert visibility is controlled programmatically.
</FodAlert>
@code {
private bool showAlert = true;
}Accessibility
Alerts automatically set appropriate ARIA roles based on severity. Info and Success use role=status with aria-live=polite. Warning and Error use role=alert with aria-live=assertive.
Info (role=status, aria-live=polite)
Error (role=alert, aria-live=assertive)
Custom Role Override
<FodAlert Color="AlertColor.Info" Role="alert">
Custom role override
</FodAlert>API Reference
Complete list of FodAlert component parameters.
