DwsAlert
The DwsAlert component displays a themed message with a Severity, optional icon, title/content, and an optional close button.
API ReferenceSeverity
The Severity parameter drives the alert's default color and icon theming.
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_Severity_Normal" Message="This is a normal alert." Severity="DwsSeverity.Normal" Icon="@Icons.BS.ChatDots" />
<DwsAlert Name="AlertDemo_Severity_Info" Message="This is an info alert." Severity="DwsSeverity.Info" Icon="@Icons.BS.InfoCircle" />
<DwsAlert Name="AlertDemo_Severity_Success" Message="This is a success alert." Severity="DwsSeverity.Success" Icon="@Icons.BS.CheckCircle" />
<DwsAlert Name="AlertDemo_Severity_Warning" Message="This is a warning alert." Severity="DwsSeverity.Warning" Icon="@Icons.BS.ExclamationTriangle" />
<DwsAlert Name="AlertDemo_Severity_Error" Message="This is an error alert." Severity="DwsSeverity.Error" Icon="@Icons.BS.DashCircle" />Alert.razor.cs
// No additional code-behind is required for this example.Appearance
Filled, outlined and text appearances.
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_Appearance_Filled" Message="Filled appearance (default)." Severity="DwsSeverity.Info" Appearance="DwsAppearance.Filled" Icon="@Icons.BS.InfoCircle" />
<DwsAlert Name="AlertDemo_Appearance_Outline" Message="Outline appearance." Severity="DwsSeverity.Warning" Appearance="DwsAppearance.Outline" Icon="@Icons.BS.ExclamationTriangle" />
<DwsAlert Name="AlertDemo_Appearance_Text" Message="Text appearance." Severity="DwsSeverity.Error" Appearance="DwsAppearance.Text" Icon="@Icons.BS.DashCircle" />Alert.razor.cs
// No additional code-behind is required for this example.Shape
Round (default) or square corners.
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_Shape_Round" Message="Round shape (default)." Severity="DwsSeverity.Info" Shape="DwsShape.Round" Icon="@Icons.BS.InfoCircle" />
<DwsAlert Name="AlertDemo_Shape_Square" Message="Square shape." Severity="DwsSeverity.Info" Shape="DwsShape.Square" Icon="@Icons.BS.InfoCircle" />Alert.razor.cs
// No additional code-behind is required for this example.Title and Content
A Title alongside rich Content, with no icon.
Upload complete
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_TitleContent_Example" Severity="DwsSeverity.Success" TitleText="Upload complete" ShowIcon="false">
<Content>
<span>Your file was uploaded. <DwsLink Name="AlertDemo_TitleContent_Link" Href="file-upload">View details</DwsLink>.</span>
</Content>
</DwsAlert>Alert.razor.cs
// No additional code-behind is required for this example.Dense mode
Dense tightens spacing for compact layouts.
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_Dense_Example" Message="Dense alert for tight spaces." Severity="DwsSeverity.Normal" Icon="@Icons.BS.ChatDots" Dense="true" />Alert.razor.cs
// No additional code-behind is required for this example.Elevation
Elevation adds a drop-shadow, from 0 (none) to 5 (deepest).
Show Code
Alert.razor
<DwsAlert Name="AlertDemo_Elevation_Example" Message="Elevated alert." Severity="DwsSeverity.Success" Icon="@Icons.BS.CheckCircle" Elevation="3" />Alert.razor.cs
// No additional code-behind is required for this example.Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| Message | string | string.Empty | Simple text content of the alert body, shown when Content is not provided. |
| Content | RenderFragment? | null | Rich content for the alert body, overriding Message when provided. |
| TitleText | string? | null | Simple title text, shown when TitleContent is not provided. |
| TitleContent | RenderFragment? | null | Rich title content, overriding TitleText when provided. |
| Icon | string | string.Empty | Optional icon CSS class rendered at the start of the alert. |
| ShowIcon | bool | true | Toggles whether Icon is rendered. |
| Severity | DwsSeverity | DwsSeverity.Normal | Semantic severity: Normal, Info, Success, Warning, or Error. Drives the default theme color. |
| Appearance | DwsAppearance | DwsAppearance.Filled | Visual style: Filled, Outline, or Text. |
| Shape | DwsShape | DwsShape.Round | Corner shape: Round or Square. |
| Elevation | int? | null | Drop-shadow depth from 0 (none) to 5 (deepest). |
| Dense | bool | false | Reduces padding/spacing for tight layouts. |
| ContentAlignment | DwsHorizontalAlignment | DwsHorizontalAlignment.None | Horizontal text alignment of the title/content. |
| Margin | int? | null | Outer margin in pixels. |
| Padding | int? | null | Inner padding in pixels. |
| BorderWidth | int? | null | Border width in pixels. |
| BorderStyle | DwsBorderStyle | DwsBorderStyle.None | Border line style. |
| BorderColor | DwsColor | DwsColor.Undefined | Overrides the border color; defaults to the Severity color. |
| AllowClose | bool | false | Shows a close button that hides the alert and raises OnClose. |
| AutoDismissAfter | int? | null | Hides the alert by itself this many milliseconds after it became visible, raising VisibleChanged and OnHide like Hide(). The timer waits while the pointer is over the alert or the focus is in it. Null or 0: the alert stays until it is closed. |
| OnClose | EventCallback | - | Raised when the user clicks the close button, before the alert hides. |
| VisibleChanged | EventCallback<bool> | - | Enables two-way binding of the inherited Visible parameter (@bind-Visible). |
| OnShow | EventCallback | - | Raised whenever the alert becomes visible. |
| OnHide | EventCallback | - | Raised whenever the alert becomes hidden. |
| AnimationMode | DwsAlertAnimationMode | DwsAlertAnimationMode.Fade | Transition played when the alert shows: None, Fade, Slide, or Collapse. |
| AnimationSpeed | DwsAnimationSpeed | DwsAnimationSpeed.Normal | Duration of the show/hide transition. |
| AriaLabel | string? | null | Overrides the automatically resolved aria-label. |
| Role | string? | null | ARIA role. Null: "status" for an alert already on the page when it loads, "alert" (announced at once) when it is shown later. Set "alert", "status" or "none" to override. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Element | ElementReference | The associated web component. May be null if accessed before the component is rendered. | |
| ComponentGuid | Guid | Unique identifier for the component. | |
| TypeString | string | The name of the component type, obtained from reflection. | |
| Authorized_RegisterEnabled | bool | false | Indicates whether this component is enabled through a permission registry. |
| Authorized_RegisterSelected | bool | false | Indicates whether this component is selected in permission selection mode. |
| GetInitializedState | bool | false | Returns whether the component is initialized. |
| GetRenderModeState | DwsRenderMode | Returns the current render mode. | |
| GetComponentState | DwsComponentStateType | Returns the current component state. | |
| GetIsInteractiveState | bool | false | Returns whether the component is interactive. |
| GetIsPrerenderingState | bool | false | Returns whether the component is prerendering. |
| GetComponentLoadingState | bool | false | Returns whether the component is loading. |
| IsFormBusy | bool | false | Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState). |
| Name | Typ | Parameters | Description |
|---|---|---|---|
| DebugInfo | void | Logs debug information about the component. | |
| UpdateState | void | Updates the component's state and triggers StateHasChanged. | |
| UpdateStateAsync | Task | Asynchronously updates the component's state and triggers StateHasChanged. | |
| Dispose | void | Disposes the component and releases resources. | |
| FocusAsync | ValueTask | bool containedInScrollableList | Sets focus to the component's element. |
| Name | Typ | Default | Description |
|---|---|---|---|
| Name | string | Required unique identifier for the component within its container. | |
| Visible | bool | true | Determines if the component is visible in the UI. |
| Disabled | bool | false | Disables the form control, ensuring it doesn't participate in form submission. |
| ComponentNameSpace | string | The namespace for permission-based access control. | |
| PermissionKey | string? | null | A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins. |
| Class | string | Optional CSS class names. | |
| Style | string | Optional in-line styles. | |
| Tag | object | An optional user-defined object to store any additional data with the component. | |
| BackReference | DwsReference | A reference to the enclosing component. | |
| ID | string | The HTML ID attribute for the component. | |
| AdditionalAttributes | Dictionary<string, object> | Additional HTML attributes for the component's root element. | |
| IgnorePermissionChecks | bool | false | Bypasses all permission checks for this component. |
| IgnorePermissionSelection | bool | false | Ignore permission selection mode for this component. |
| IgnoreFormBusy | bool | false | Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it. |
| Name | Typ | Description |
|---|---|---|
| OnInitializedCallbackStarted | EventCallback | Callback when OnInitialized starts. |
| OnInitializedCallback | EventCallback | Callback during OnInitialized. |
| OnInitializedCallbackCompleted | EventCallback | Callback when OnInitialized completes. |
| OnInitializedAsyncCallbackStarted | EventCallback | Callback when OnInitializedAsync starts. |
| OnInitializedAsyncCallback | EventCallback | Callback during OnInitializedAsync. |
| OnInitializedAsyncCallbackCompleted | EventCallback | Callback when OnInitializedAsync completes. |
| OnIsComponentLoadingChanged | EventCallback<bool> | Callback when IsComponentLoading changes. |
| OnCurrentRenderModeChanged | EventCallback<DwsRenderMode> | Callback when CurrentRenderMode changes. |
| OnComponentStateChanged | EventCallback<DwsComponentStateType> | Callback when ComponentState changes. |
