Alert
Displays important messages or notifications with variant styling (default, destructive).
Installation
Add the Alert component using the CLI:
Usage
The Alert component displays important messages or notifications. Use ChildContent to render your message. Set Variant to AlertVariant.Default or AlertVariant.Destructive for different styling.
Examples
Icons
Although support for icons deos not natively exist, you can structure your alerts to use icons (for example from Lucide) like so:
Variants
Use the Variant parameter to switch between default and destructive styling for error or warning messages. Only two variants are provided by default.
Interactivity
You can embed other components into alerts to add interactivity.
Styling
Customize alert colors by adding Tailwind classes like bg-amber-50 dark:bg-amber-950. Use the group utility on the Alert to trigger hover animations on child elements:
API Reference
Alert
A contextual alert message for displaying important information to the user.
Properties
| Name | Type | Description |
|---|---|---|
AdditionalAttributes |
Dictionary<string, Object> |
|
ChildContent |
RenderFragment |
The content of the alert. |
Class |
string |
|
Variant |
AlertVariant |
The visual style variant of the alert. |
Methods
| Method | Returns | Description |
|---|---|---|
Equals |
bool |
|
GetHashCode |
int |
|
GetType |
Type |
|
SetParametersAsync |
Task |
|
ToString |
string |