Notifications
Badge
Badge is the small marker that sits on another element and reports what is waiting behind it. It takes a number, a string, an icon or a template, caps a count at a max, hides itself when that count reaches zero, or drops its content altogether and becomes a dot. It anchors to any of fifteen positions around its child - physical or direction-aware - and can be nudged, overlapped, ringed against a busy background or given a pulse while something is in progress. It can also step out of the overlay and sit beside its child in the flow, or stand entirely on its own where there is nothing to overlay. It turns into a real keyboard-operable button as soon as it is given a click handler and into a real link as soon as it is given a URL, and carries a text alternative and a live region so that what it says visually also reaches a screen reader.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
63
Variant
Shape
Dot
Max
int - and leaves a string content untouched. A capped badge is the one a reader
cannot get the real figure out of, so it carries that figure as its tooltip on its own: hover the second badge below and it reads 100. Title overrides
that wherever there is something better to say than the number itself, as the third one does.
ShowZero
true by default, so the zero is rendered; set it to false and the
badge disappears on its own, which saves keeping a Hidden flag of your own next to the count. An icon or a
ContentTemplate is content of its own rather than a number, so it keeps the badge on the page and only the emptied count is taken off it.
Content
ToString().
A template is content of its own, so it is what the badge shows and what keeps it on the page: neither Max nor ShowZero reads it.
A badge given no content, no icon and no template at all has nothing to report and is not rendered, so a counter bound to nothing leaves no empty mark behind.
Text
99%
Position
Overlap
Offset
Bordered



Pulse
Standalone
Inline
Inbox
24Alerts
3Build server
OperationalReports
BetaHidden
63
Events
Link
rel="noopener",
which keeps the opened page from reaching back into this one. OnClick can be set alongside it, in which case the handler runs and the navigation still
happens. Disabling the badge drops the href and takes the badge out of the tab order, so a disabled link cannot be followed by either the pointer or the keyboard.
Accessibility
Color
External Icons
Size
Style & Class
--bit-bdg-clr and --bit-bdg-clr-txt for a color
outside the theme roles, --bit-bdg-clr-ring for the color a Bordered ring is drawn in,
--bit-bdg-gap for the room between an inline badge and its child, and --bit-bdg-zin for the
layer an overlaid badge is painted on, which it sits one above its child on by default so nothing the child raises can cover it.
Wider gap
84RTL
جدید
پیشنویس
API
Every parameter, public member, sub-class and enum this component exposes.
BitBadge parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Bordered | bool | false | Draws a ring around the badge in the color of the page behind it, so it stays legible over a busy child such as an avatar or an image. |
| ChildContent | RenderFragment? | null | Child content of component, the content that the badge will apply to. When it is not set the badge renders standalone, in the normal flow of the page. |
| Classes | BitBadgeClassStyles? | null | Custom CSS classes for different parts of the BitBadge. |
| Color | BitColor? | null | The general color of the badge. |
| Content | object? | null | Content you want inside the badge. A number is capped by Max and hidden by ShowZero when it is zero, a string is rendered as it is, and any other value is rendered through its ToString(). A badge given no content, no icon and no template at all is not rendered. |
| ContentTemplate | RenderFragment? | null | The custom template to render inside the badge, in place of Content. A template is content of its own, so neither Max nor ShowZero reads it, and it is markup rather than words, so a Live badge showing one needs a Description before its live region has anything to announce. |
| Description | string? | null | The text alternative of the badge for assistive technologies, for example "5 unread messages". It is rendered into the badge visible only to assistive technologies, and hides the visual content from them so the two are not announced twice. |
| Dot | bool | false | Reduces the size of the badge and hide any of its content. |
| Hidden | bool | false | The visibility of the badge. A hidden badge is removed from the DOM while its child content keeps rendering. |
| Href | string? | null | The URL the badge navigates to, which also turns the badge into a link: an anchor that is focusable, offers the context menu and the middle click, and is announced as a link. While IsEnabled is false the href is dropped and the badge leaves the tab order. |
| Icon | BitIconInfo? | null | Gets or sets the icon to display using custom CSS classes for external icon libraries. Takes precedence over IconName when both are set. |
| IconName | string? | null | Gets or sets the name of the icon to display from the built-in Fluent UI icons. |
| Inline | bool | false | Lays the badge out next to its child content in the normal flow of the page instead of over it. Overlap stops applying and only the side of Position is read: the Start and Left families put the badge before the child content, every other one after it. |
| Live | bool | false | Announces the badge to assistive technologies whenever its content changes, by turning it into a polite live region. The region is kept on the page whether or not the badge itself is, so a counter that appears, changes and disappears is announced every time. It reads out the Description when there is one and the counter itself otherwise. |
| Max | int? | null | Max value to display when content is a number. A content above it renders as the max followed by a plus sign, for example 99+, and the badge carries the figure it shortened as its tooltip unless a Title of its own says something better. |
| OffsetX | string? | null | Moves the badge along the horizontal axis by the given CSS length, on top of its Position. A positive value moves the badge to the right in both directions of writing. |
| OffsetY | string? | null | Moves the badge along the vertical axis by the given CSS length, on top of its Position. A positive value moves the badge down. |
| OnClick | EventCallback<MouseEventArgs> | The click event of the badge, which also turns the badge into a keyboard-operable button. | |
| Overlap | bool | false | Overlaps the badge on top of the child content. |
| Position | BitPosition? | null | The position of the badge. The Left/Right positions are physical, while the Start/End ones follow the direction of writing. |
| Pulse | bool | false | Renders an expanding ring around the badge to report that something is in progress. |
| Rel | BitLinkRels? | null | The relationship between the current document and the one the Href of the badge leads to. With no value of its own, a badge opening in a new browsing context gets rel="noopener" automatically. |
| Reversed | bool | false | Reverses the direction flow of the content of the badge, which puts the icon after the content. |
| Shape | BitBadgeShape? | null | The corner shape of the badge. |
| ShowZero | bool | true | Renders the badge when its content is the number zero. Turn it off for a counter that should disappear once it is emptied. Only a numeric Content counts as zero, and a string is rendered as it is. An icon or a ContentTemplate is content of its own, so it keeps the badge on the page and only the emptied number is taken off it. |
| Size | BitSize? | null | The size of badge, Possible values: Small | Medium | Large |
| Styles | BitBadgeClassStyles? | null | Custom CSS styles for different parts of the BitBadge. |
| Target | string? | null | The browsing context the Href of the badge is opened in, for example _blank. |
| Title | string? | null | The tooltip to show when the mouse is placed on the badge. It is rendered on the badge itself rather than on the child content underneath it. A badge whose Max has capped its count already spells that count out on hover, so this is only needed when there is something better to say than the figure itself. A title is not a text alternative, so what a screen reader should hear belongs in Description. |
| Variant | BitVariant? | null | The visual variant of the badge. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | bool | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitBadgeClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitBadge. |
| BadgeWrapper | string? | null | Custom CSS classes/styles for the badge wrapper of the BitBadge. |
| Badge | string? | null | Custom CSS classes/styles for the badge of the BitBadge. |
| Icon | string? | null | Custom CSS classes/styles for the icon of the BitBadge. |
| Content | string? | null | Custom CSS classes/styles for the content of the BitBadge. |
| Description | string? | null | Custom CSS classes/styles for the visually hidden description of the BitBadge. |
| LiveRegion | string? | null | Custom CSS classes/styles for the visually hidden live region of the BitBadge, rendered while Live is on and the badge is not a button. |
BitIconInfo properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Name | string? | null | Gets or sets the name of the icon. |
| BaseClass | string? | null | Gets or sets the base CSS class for the icon. For built-in Fluent UI icons, this defaults to "bit-icon". For external icon libraries like FontAwesome, you might set this to "fa" or leave empty. |
| Prefix | string? | null | Gets or sets the CSS class prefix used before the icon name. For built-in Fluent UI icons, this defaults to "bit-icon--". For external icon libraries, you might set this to "fa-" or leave empty. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Info Primary general color. |
| Secondary | 1 | Secondary general color. |
| Tertiary | 2 | Tertiary general color. |
| Info | 3 | Info general color. |
| Success | 4 | Success general color. |
| Warning | 5 | Warning general color. |
| SevereWarning | 6 | SevereWarning general color. |
| Error | 7 | Error general color. |
| PrimaryBackground | 8 | Primary background color. |
| SecondaryBackground | 9 | Secondary background color. |
| TertiaryBackground | 10 | Tertiary background color. |
| PrimaryForeground | 11 | Primary foreground color. |
| SecondaryForeground | 12 | Secondary foreground color. |
| TertiaryForeground | 13 | Tertiary foreground color. |
| PrimaryBorder | 14 | Primary border color. |
| SecondaryBorder | 15 | Secondary border color. |
| TertiaryBorder | 16 | Tertiary border color. |
BitSize enum
| Name | Value | Description |
|---|---|---|
| Small | 0 | The small size badge. |
| Medium | 1 | The medium size badge. |
| Large | 2 | The large size badge. |
BitBadgeShape enum
| Name | Value | Description |
|---|---|---|
| Circular | 0 | Fully rounded corners, so a counter reads as a circle and a longer label as a pill. |
| Rounded | 1 | The corner radius the current theme gives to its controls. |
| Square | 2 | Square corners with no radius at all. |
BitPosition enum
| Name | Value | Description |
|---|---|---|
| TopLeft | 0 | |
| TopCenter | 1 | |
| TopRight | 2 | |
| TopStart | 3 | |
| TopEnd | 4 | |
| CenterLeft | 5 | |
| Center | 6 | |
| CenterRight | 7 | |
| CenterStart | 8 | |
| CenterEnd | 9 | |
| BottomLeft | 10 | |
| BottomCenter | 11 | |
| BottomRight | 12 | |
| BottomStart | 13 | |
| BottomEnd | 14 |
BitVariant enum
| Name | Value | Description |
|---|---|---|
| Fill | 0 | Fill styled variant. |
| Outline | 1 | Outline styled variant. |
| Text | 2 | Text styled variant. |
BitLinkRels enum
| Name | Value | Description |
|---|---|---|
| Alternate | 1 | Provides a link to an alternate representation of the document. (i.e. print page, translated or mirror) |
| Author | 2 | Provides a link to the author of the document. |
| Bookmark | 4 | Permanent URL used for bookmarking. |
| External | 8 | Indicates that the referenced document is not part of the same site as the current document. |
| Help | 16 | Provides a link to a help document. |
| License | 32 | Provides a link to licensing information for the document. |
| Next | 64 | Provides a link to the next document in the series. |
| NoFollow | 128 | Links to an unendorsed document, like a paid link. ("NoFollow" is used by Google, to specify that the Google search spider should not follow that link) |
| NoOpener | 256 | Requires that any browsing context created by following the hyperlink must not have an opener browsing context. |
| NoReferrer | 512 | Makes the referrer unknown. No referrer header will be included when the user clicks the hyperlink. |
| Prev | 1024 | The previous document in a selection. |
| Search | 2048 | Links to a search tool for the document. |
| Tag | 4096 | A tag (keyword) for the current document. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.