Badge

Small numerical value or status descriptor for UI elements.
Importimport{ Badge }from"antd";

When To Use

Badge normally appears in proximity to notifications or user avatars with eye-catching appeal, typically displaying unread messages count.

Examples

5
0

Simplest Usage. Badge will be hidden when count is 0, but we can use showZero to show it.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
99
99+
10+
999+

${overflowCount}+ is displayed when count is larger than overflowCount. The default value of overflowCount is 99.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5

The count will be animated as it changes.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5

Set offset of the badge dot, the format is [left, top], which represents the offset of the status dot from the left and top of the default position.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

Success
Error
Default
Processing
Warning

Standalone badge with status.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies
Pushes open the window
and raises the spyglass.
Hippies

Use ribbon badge.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
11
25
99+

Used in standalone when children is empty.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

This will simply display a red badge, without a specific count. If count equals 0, it won't display the dot.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5
5

Set size of numeral Badge.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
pink
red
yellow
orange
cyan
green
blue
purple
geekblue
magenta
volcano
gold
lime
#f50
rgb(45, 183, 245)
hsl(102, 53%, 61%)
hwb(205 6% 9%)

We preset a series of colorful Badge styles for use in different situations. You can also set it to a hex color string for custom color.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code

API

Common props ref:Common props

Badge

PropertyDescriptionTypeDefaultVersion
colorCustomize Badge dot colorstring-
countNumber to show in badgeReactNode-
classNamesSemantic DOM classRecord<SemanticDOM, string>-5.7.0
dotWhether to display a red dot instead of countbooleanfalse
offsetSet offset of the badge dot[number, number]-
overflowCountMax count to shownumber99
showZeroWhether to show badge when count is zerobooleanfalse
sizeIf count is set, size sets the size of badgedefault | small--
statusSet Badge as a status dotsuccess | processing | default | error | warning-
stylesSemantic DOM styleRecord<SemanticDOM, CSSProperties>-5.7.0
textIf status is set, text sets the display text of the status dotReactNode-
titleText to show when hovering over the badgestring-

Badge.Ribbon

PropertyDescriptionTypeDefaultVersion
colorCustomize Ribbon colorstring-
placementThe placement of the Ribbon, start and end follow text direction (RTL or LTR)start | endend
textContent inside the RibbonReactNode-

Semantic DOM

5
  • root
    5.7.0
    Root element
  • indicator
    5.7.0
    Indicator element

Design Token

Component TokenHow to use?

Token NameDescriptionTypeDefault Value
dotSizeSize of dot badgenumber6
indicatorHeightHeight of badgestring | number20
indicatorHeightSMHeight of small badgestring | number14
indicatorZIndexz-index of badgestring | numberauto
statusSizeSize of status badgenumber6
textFontSizeFont size of badge textnumber12
textFontSizeSMFont size of small badge textnumber12
textFontWeightFont weight of badge textstring | numbernormal

Global TokenHow to use?