DwsBadge
The DwsBadge component can be used to display status indicators and notification badges, either standalone or as an overlay wrapped around another component.
API ReferenceNotification badges
BadgeType Notification shows a count or short text next to the icon.
1
99+
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_Badge01" Icon="@Icons.Solid.Square" Content="1" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" />
<DwsBadge Name="BadgeDemo_Badge02" Icon="@Icons.Solid.Square" Content="99+" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Error" />Badge.razor.cs
// No additional code-behind is required for this example.Maximum count
Max caps a numeric Content: 150 with Max 99 shows 99+.
99+
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeMax" Icon="@Icons.Solid.Square" Content="150" Max="99" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Error" />Badge.razor.cs
// No additional code-behind is required for this example.Status badges
BadgeType Status shows a coloured status point; the Tooltip names the status.
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_Badge03" Icon="@Icons.Solid.Square" BadgeType="DwsBadgeType.Status" Color="DwsColor.Success" Tooltip="Online" />
<DwsBadge Name="BadgeDemo_Badge04" Icon="@Icons.Solid.Square" BadgeType="DwsBadgeType.Status" Color="DwsColor.Warning" Tooltip="Away" />
<DwsBadge Name="BadgeDemo_Badge05" Icon="@Icons.Solid.Square" BadgeType="DwsBadgeType.Status" Color="DwsColor.Error" Tooltip="Offline" />Badge.razor.cs
// No additional code-behind is required for this example.Badges as Overlays
Wrap any component (icon, button, avatar) with DwsBadge to anchor the badge to one of its corners.
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeOverlay01" Content="3" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Error" Position="DwsBadgePosition.TopRight">
<DwsIcon Name="BadgeDemo_BellIcon" Icon="@Icons.Solid.Bell" Style="font-size: 2rem;" AriaLabel="Notifications" />
</DwsBadge>
<DwsBadge Name="BadgeDemo_BadgeOverlay02" Content="5" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Warning" Position="DwsBadgePosition.TopRight" class="ms-4">
<DwsButton Name="BadgeDemo_MessagesButton" Color="DwsColor.Primary">Messages</DwsButton>
</DwsBadge>
<DwsBadge Name="BadgeDemo_BadgeOverlay03" BadgeType="DwsBadgeType.Status" Color="DwsColor.Success" IsDot="true" Position="DwsBadgePosition.BottomRight"
IsBordered="true" Overlap="DwsBadgeOverlap.Circular" Tooltip="Online" class="ms-4">
<DwsIcon Name="BadgeDemo_UserIcon" Icon="@Icons.Solid.CircleUser" Style="font-size: 2rem;" AriaLabel="User" />
</DwsBadge>Badge.razor.cs
// No additional code-behind is required for this example.Badges with Icons
Badges with icons and content
3
5
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeIcon01" Icon="@Icons.Solid.Bell" Content="3" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" />
<DwsBadge Name="BadgeDemo_BadgeIcon02" Icon="@Icons.Solid.Envelope" Content="5" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Info" />
<DwsBadge Name="BadgeDemo_BadgeIcon03" Icon="@Icons.Solid.Circle" BadgeType="DwsBadgeType.Status" Color="DwsColor.Success" Tooltip="Online" />
<DwsBadge Name="BadgeDemo_BadgeIcon04" Icon="@Icons.Solid.MapPin" BadgeType="DwsBadgeType.Status" Color="DwsColor.Warning" Tooltip="Away" />
<DwsBadge Name="BadgeDemo_BadgeIcon05" Icon="@Icons.Solid.MapPin" BadgeType="DwsBadgeType.Status" Color="DwsColor.Error" Tooltip="Offline" />Badge.razor.cs
// No additional code-behind is required for this example.Badges with Tooltips
Badges with tooltips
New
99+
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeTooltip01" Content="New" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" Tooltip="New notifications" />
<DwsBadge Name="BadgeDemo_BadgeTooltip02" Content="99+" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Error" Tooltip="99+ unread messages" />
<DwsBadge Name="BadgeDemo_BadgeTooltip03" BadgeType="DwsBadgeType.Status" Color="DwsColor.Success" Tooltip="User is online" />
<DwsBadge Name="BadgeDemo_BadgeTooltip04" BadgeType="DwsBadgeType.Status" Color="DwsColor.Warning" Tooltip="User is away" />
<DwsBadge Name="BadgeDemo_BadgeTooltip05" BadgeType="DwsBadgeType.Status" Color="DwsColor.Error" Tooltip="User is offline" />Badge.razor.cs
// No additional code-behind is required for this example.Badges with Different Colors
Badges with different colors
Primary
Secondary
Success
Info
Warning
Error
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeColor01" Content="Primary" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" />
<DwsBadge Name="BadgeDemo_BadgeColor02" Content="Secondary" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Secondary" />
<DwsBadge Name="BadgeDemo_BadgeColor03" Content="Success" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Success" />
<DwsBadge Name="BadgeDemo_BadgeColor04" Content="Info" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Info" />
<DwsBadge Name="BadgeDemo_BadgeColor05" Content="Warning" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Warning" />
<DwsBadge Name="BadgeDemo_BadgeColor06" Content="Error" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Error" />Badge.razor.cs
// No additional code-behind is required for this example.Appearance
Filled vs. outlined badges.
Filled
Outline
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeAppearance01" Content="Filled" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" Appearance="DwsAppearance.Filled" />
<DwsBadge Name="BadgeDemo_BadgeAppearance02" Content="Outline" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Primary" Appearance="DwsAppearance.Outline" />Badge.razor.cs
// No additional code-behind is required for this example.Shape
IsRounded picks rounded (pill) or square corners.
Rounded
Square
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeAppearance03" Content="Rounded" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Info" IsRounded="true" />
<DwsBadge Name="BadgeDemo_BadgeAppearance04" Content="Square" BadgeType="DwsBadgeType.Notification" Color="DwsColor.Info" IsRounded="false" />Badge.razor.cs
// No additional code-behind is required for this example.Dot indicator
IsDot renders a small dot without content.
Show Code
Badge.razor
<DwsBadge Name="BadgeDemo_BadgeAppearance05" BadgeType="DwsBadgeType.Status" Color="DwsColor.Success" IsDot="true" Tooltip="Dot indicator" />Badge.razor.cs
// No additional code-behind is required for this example.Interface-Description
| Name | Typ | Default | Description |
|---|---|---|---|
| Content | string | string.Empty | Text content of the badge (e.g. 3, 99+, New). |
| Max | int? | null | Largest count a notification badge shows in full; a larger whole number is shown as "99+" (for Max=99). The accessible name keeps the real number. |
| BadgeType | DwsBadgeType | DwsBadgeType.Notification | Badge mode: Notification or Status. |
| Color | DwsColor | DwsColor.Primary | Semantic badge color. |
| Icon | string? | null | Optional icon inside the badge. |
| Tooltip | string? | null | Optional tooltip text. |
| TooltipPosition | DwsTooltipPosition | DwsTooltipPosition.Top | Position of the tooltip relative to the badge. |
| Appearance | DwsAppearance | DwsAppearance.Filled | Appearance: Filled, Outline or None. |
| IsDot | bool | false | Shows the badge as a small dot without content. |
| IsBordered | bool | false | Adds a border to the badge (useful for overlays). |
| IsRounded | bool | true | true = pill-shaped, false = slightly rounded rectangle. |
| Position | DwsBadgePosition | DwsBadgePosition.TopRight | Corner position of the badge when it is placed as an overlay around ChildContent. |
| Overlap | DwsBadgeOverlap | DwsBadgeOverlap.Rectangular | Overlap shape relative to ChildContent (e.g. Circular for avatars). |
| Invisible | bool | false | Hides the badge; ChildContent stays visible. |
| ChildContent | RenderFragment? | null | Content the badge wraps as an overlay (e.g. Button, Avatar, Icon). |
| 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. |
