Skip to content

Badge

Badge

Badge component is used to display counts, small dots, or status markers in the upper right corner of elements, commonly used for message reminders, new feature markers, and other scenarios.

Basic Usage

Badge can be directly attached to other elements, set the displayed value through the value attribute.

Show CodeArrow
CopyGitHub

Small Dot

By setting the isDot attribute, it can be displayed as a small dot without showing specific values.

Show CodeArrow
CopyGitHub

Maximum Value

You can set the maximum display value through the max attribute. When exceeding the maximum value, it will display as "max value+".

Show CodeArrow
CopyGitHub

Custom Color

Customize the badge background color through the color attribute.

Show CodeArrow
CopyGitHub

Position Offset

You can adjust the badge position through offsetX and offsetY attributes to achieve flexible position customization.

Show CodeArrow
CopyGitHub

Hidden Badge

By setting the hiddenValue attribute, when the value equals the hidden value, the badge will not be displayed.

Current Value: 3
Show CodeArrow
CopyGitHub

Badge API

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
valueDisplayed valuenumber
isDotWhether to display as small dotbooleanfalse
maxMaximum display valuenumber99
colorBadge background colorstring#f56c6c
offsetXX-axis offsetnumber0
offsetYY-axis offsetnumber0
hiddenValueValue when hiding badgenumber0

Slots

Slot NameDescription
defaultContent element wrapped by badge

Style Variables

The badge component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$theme-color-dangerTheme color - Danger
$color-whiteWhite color
$z-index-showDisplay z-index
</rewritten_file>

Released under the MIT License