Notifications
Badge
Badge is the small marker that reports what is waiting behind another element: a count capped at a max and hidden at zero, a string, an icon, a template or a plain dot. It anchors to fifteen positions around its child, or sits beside it or on its own in the flow. Given a handler or a URL it becomes a real button or link, and a text alternative and a live region carry what it shows to screen readers.
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
63
Variant & Shape
Content
ToString()). IconName / Icon add a glyph,
Reversed puts it after the content, and ContentTemplate replaces both with your own markup. A badge given nothing to show is not rendered.
Max, ShowZero & Hidden
99+). ShowZero=false takes an emptied counter off the page,
and Hidden removes the badge while its child keeps rendering.
Dot
Position
Overlap & Offset



Bordered & Pulse


Standalone & Inline
Inbox
24Build server
OperationalOnClick & Href
_blank adds noopener).
Disabled, it leaves the tab order and drops the href. Without either, the badge never takes focus.
Accessibility
CSS variables
:root or on any ancestor - a plain element around the badges, as here - or on one badge's Style (see Style & Class).
A disabled badge keeps the theme's disabled colors.
Cascading parameters
Color
External Icons
Size
--bit-siz-badge-*), so each design-system preset sizes badges its own way.
Style & Class
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitBadge CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Badge-color | Per variant, from the Color role | Text and icon color. In the Outline variant it is also the border color. |
| --bit-Badge-background | Per variant, from the Color role | Background. In the Fill variant it is also the border color. |
| --bit-Badge-border-color | The background (Fill), the text color (Outline), transparent (Text) | Border color, in every state. |
| --bit-Badge-hover-background | Per variant, from the Color role | Background of a clickable (OnClick or Href) badge on hover. Set it together with --bit-Badge-background. |
| --bit-Badge-active-background | Per variant, from the Color role | Background of a clickable badge while pressed. |
| --bit-Badge-focus-color | The Color role's focus color | Keyboard focus ring color of a clickable badge. |
| --bit-Badge-border-width | --bit-shp-brd-width | Border width. |
| --bit-Badge-radius | Per Shape | Corner radius. A dot is always a circle. |
| --bit-Badge-height | --bit-siz-badge-{sm,md,lg}, per Size | Height, and the smallest width, which keeps a single digit a circle. |
| --bit-Badge-padding | Per Size | Padding. |
| --bit-Badge-font-size | Per Size, from the type ramp | Text size. |
| --bit-Badge-font-weight | --bit-tpg-fw-semibold | Text weight. |
| --bit-Badge-gap | spacing(0.5) | Room between the icon and the content. |
| --bit-Badge-dot-size | --bit-siz-badge-dot-{sm,md,lg}, per Size | Diameter of a Dot badge. |
| --bit-Badge-inset | spacing(0.5) | How far an overlaid badge reaches back in over the edge of its child. |
| --bit-Badge-overlap-inset | spacing(1.5) | The same inset when Overlap is on. |
| --bit-Badge-inline-gap | spacing(0.75) | Room between an Inline badge and its child. |
| --bit-Badge-z-index | 1 | Layer an overlaid badge is painted on, one above its child by default. |
| --bit-Badge-ring-color | --bit-clr-bg-pri | Color of the Bordered ring; match it to the surface behind the badge. |
| --bit-Badge-ring-width | --bit-shp-brd-width-thick | Width of the Bordered ring. |
| --bit-Badge-pulse-color | The Color role's main color | Color of the Pulse ring. |
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 | The content the badge applies to. Without it the badge renders standalone, in the 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 at zero by ShowZero; any other value renders through its ToString(). A badge with nothing to show is not rendered. |
| ContentTemplate | RenderFragment? | null | Custom markup rendered in place of Content. Max and ShowZero do not read it, and a Live badge showing one needs a Description to announce. |
| Decorative | bool | false | Hides the badge (never its child) from assistive technologies, for a badge whose focusable child already names the count. A Live region keeps announcing, and a button or link badge is never hidden. |
| Description | string? | null | Text alternative for assistive technologies (e.g. "5 unread messages"), read in place of the visible content. On a button or link badge named by an AriaLabel it describes the control instead; on a plain dot or icon-only badge the AriaLabel stands in for it, while a badge showing a count keeps saying the count. |
| Dot | bool | false | Reduces the size of the badge and hides any of its content. Pair it with a Description. |
| 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 | Turns the badge into a real link to the URL. While Disabled is true 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 beside its child content instead of over it. Overlap no longer applies and only the side of Position is read: Start/Left before the child, the rest after. |
| Live | bool | false | Announces every change of the badge through a polite live region, including it appearing and disappearing. Reads the Description, or the counter itself. |
| Max | int? | null | Caps a numeric Content: above it the badge shows the max followed by a plus (99+) and the real figure as its tooltip, shown wherever the badge takes the pointer (an overlaid one leaves it to its child). |
| 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> | Turns the badge into a real, keyboard-operable button. The click does not reach the element underneath. | |
| Overlap | bool | false | Pulls the badge in over the child content, for a child with a rounded outline such as an avatar. |
| 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. Under reduced motion it stops and stays as a still halo. |
| 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 | BitShape? | null | The corner shape of the badge. Only Pill, Rounded and Square are honoured: a badge takes its box from its own content, so Circle has no proportions to impose and falls back to the default. |
| ShowZero | bool | true | Renders the badge when its numeric Content is zero. Turn it off to hide an emptied counter; an icon or a ContentTemplate keeps the badge on the page. |
| Size | BitSize? | null | The size of the badge: its height, type size and padding, and the diameter of a dot. |
| 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 of the badge itself (not of its child). Replaces the real figure a capped count shows on its own. Not a text alternative: use Description for screen readers. An overlaid badge lets the pointer through to its child, so its tooltip shows once it is standalone, inline or clickable. |
| 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. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| 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. |
| 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. |
BitShape enum
| Name | Value | Description |
|---|---|---|
| Rounded | 0 | The corner radius the current theme gives to this kind of surface. |
| Square | 1 | Sharp corners with no radius at all. |
| Pill | 2 | Fully rounded ends: a pill where the box is wider than it is tall, and a circle where the box is square. |
| Circle | 3 | A true circle, which takes its diameter from whichever of the height and the width is set. |
BitPosition enum
| Name | Value | Description |
|---|---|---|
| TopLeft | 0 | The top left corner, in both reading directions. |
| TopCenter | 1 | The top edge, centered horizontally. |
| TopRight | 2 | The top right corner, in both reading directions. |
| TopStart | 3 | The top edge, on the side the reading direction starts from. |
| TopEnd | 4 | The top edge, on the side the reading direction ends at. |
| CenterLeft | 5 | The left edge, centered vertically, in both reading directions. |
| Center | 6 | Centered both ways. |
| CenterRight | 7 | The right edge, centered vertically, in both reading directions. |
| CenterStart | 8 | Centered vertically, on the side the reading direction starts from. |
| CenterEnd | 9 | Centered vertically, on the side the reading direction ends at. |
| BottomLeft | 10 | The bottom left corner, in both reading directions. |
| BottomCenter | 11 | The bottom edge, centered horizontally. |
| BottomRight | 12 | The bottom right corner, in both reading directions. |
| BottomStart | 13 | The bottom edge, on the side the reading direction starts from. |
| BottomEnd | 14 | The bottom edge, on the side the reading direction ends at. |
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. |
| Me | 8192 | Indicates that the linked document represents the person who owns the current content. (used for identity verification) |
| Opener | 16384 | Requires that any browsing context created by following the hyperlink keeps its opener browsing context. (reverses the implicit noopener modern browsers apply to _blank targets) |
| PrivacyPolicy | 32768 | Links to the privacy policy that applies to the current document. (rendered as privacy-policy) |
| Sponsored | 65536 | Marks the link as an advertisement or paid placement, so search engines do not count it as an organic endorsement. |
| TermsOfService | 131072 | Links to the terms of service that apply to the current document. (rendered as terms-of-service) |
| Ugc | 262144 | Marks the link as user-generated content, like forum posts or comments, for search engines. |
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.