CounterBadge

The FluentCounterBadge component is used to display a notification count on top of another component.

Examples

Appearances

First example: A "+" can be shown after the Count when its value is larger than the set Max value. To achieve this, set the ShowOverflow parameter to true (which is the default).

Second example: The HorizontalPosition and VerticalPosition parameters (int, used as a percentage) can be used to position the counter badge. The default values for both are 50(%). It is possible to supply negative values as is shown in this example.

Last example: When the Dot parameter is set to 'true', the Count will be ignored. Just a dot will be displayed.

Example
99+
5
5
5
9
Download: 

Dot

When the Dot parameter is set to 'true', the Count will be ignored. Just a dot will be displayed.
Example
Show dot
Download: 

Conditions

The counter badge will, by default, not be shown when the Count equals 0. It is possible to control the conditions when the counter will be shown on the badge by using the ShowWhen parameter. By default, the counter will not be shown when the Count value equals 0 (first example). Several examples are shown here.

Example
Parameters: Count="0", ShowWhen not specified. Result:
Parameters: Count="0", ShowWhen="@(Count => Count >= 0)". Result:
0
Parameters: Count="-4", ShowWhen="@(Count => Count <= 0)". Result:
-4
Parameters: Count="-4", ShowWhen="@(Count => Count > 3)". Result:
Parameters: Count="4", ShowWhen="@(Count => Count > 3)". Result:
4
Download: 

Specific content

The BadgeTemplate parameter can be used to display specific content on the badge. The Count value is available within the template through the @context parameter.

Example
Count: 10!
Download: 

Documentation

FluentCounterBadge Class

Parameters

Name
Type
Default
Description
AppearanceAppearance?
Accent
Gets or sets the default design of this badge using colors from theme.
BackgroundColorColor?
Gets or sets the background color to replace the color inferred from property.
BadgeContentRenderFragment?
Gets or sets the content you want inside the badge, to customize the badge content.
BadgeTemplateRenderFragment<int?>?
Gets or sets the content you want inside the badge, to customize the badge content.
BottomPositionint
60
Gets or sets the bottom position of the badge in percentage.
[Obsolete] This parameter will be removed in a future version. Use VerticalPosition instead.
Default value is 60 (80 when Dot=true).
ChildContentRenderFragment?
Gets or sets the child content of component, the content that the badge will apply to.
ColorColor?
Gets or sets the font color to replace the color inferred from property.
Countint?
Gets or sets the number displayed inside the badge.
Can be enriched with a plus sign with FluentCounterBadge.ShowOverflow
Dotbool
False
Gets or sets if just a dot should be displayed. Count will be ignored if this is set to true.
Defaults to false.
HorizontalPositionint?
Gets or sets the horizontal position of the badge in percentage in relation to the left of the container (right in RTL).
Default value is 60 (80 when Dot=true).
Maxint?
99
Gets or sets the maximum number that can be displayed inside the badge.
Default is 99.
ShowOverflowbool
True
If an plus sign should be displayed when the FluentCounterBadge.Count is greater than FluentCounterBadge.Max.
Defaults to true.
ShowWhenFunc<int?, bool>
Gets or sets if the counter badge is displayed based on the specified lambda expression.
For example to show the badge when the count greater than 4, use ShowWhen=@(Count => Count > 4)
Default the badge shows when the count is greater than 0.
ShowZerobool
False
If the counter badge should be displayed when the count is zero.
Defaults to false.
[Obsolete] This parameter will be removed in a future version. Use ShowWhen with a lambda expression instead
For getting the same behavior as before, you can use ShowWhen='@(Count => Count >= 0)'
VerticalPositionint?
Gets or sets the vertical position of the badge in percentage in relation to the bottom of the container.
Default value is 60 (80 when Dot=true).
Neutral
Accent
Hypertext
Lightweight
Outline
Stealth
Filled
Neutral
Accent
Warning
Info
Error
Success
Fill
FillInverse
Lightweight
Disabled
Custom
Neutral
Accent
Warning
Info
Error
Success
Fill
FillInverse
Lightweight
Disabled
Custom
An error has occurred. This application may no longer respond until reloaded. Reload 🗙