Badge
Small numerical value or status descriptor for UI elements.
When To Use
Badge normally appears in proximity to notifications or user avatars with eye-catching appeal, typically displaying unread messages count.
Examples
- Basic ·
basic - Standalone ·
no-wrapper - Overflow Count ·
overflow - Red badge ·
dot - Dynamic ·
change - Clickable ·
link - Offset ·
offset - Size ·
size - Status ·
status - Colorful Badge ·
colorful - Ribbon ·
ribbon - Custom semantic dom styling ·
style-class
API
Common props ref:Common props
Badge
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| color | Customize Badge dot color | string | - | × | |
| count | Number to show in badge | ReactNode | - | × | |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 5.7.0 | |
| dot | Whether to display a red dot instead of count | boolean | false | × | |
| offset | Set offset of the badge dot | [number, number] | - | × | |
| overflowCount | Max count to show | number | 99 | × | |
| showZero | Whether to show badge when count is zero | boolean | false | × | |
| size | If count is set, size sets the size of badge | medium | small | - | - | × |
| status | Set Badge as a status dot | success | processing | default | error | warning | - | × | |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 5.7.0 | |
| text | If status is set, text sets the display text of the status dot | ReactNode | - | × | |
| title | Text to show when hovering over the badge. Set to null or false to remove the native tooltip | string | null | false | - | 6.5.0 | × |
Badge.Ribbon
| Property | Description | Type | Default | Version | Global Config |
|---|---|---|---|---|---|
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string> | - | 6.0.0 | |
| color | Customize Ribbon color | string | - | × | |
| placement | The placement of the Ribbon, start and end follow text direction (RTL or LTR) | start | end | end | × | |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties> | - | 6.0.0 | |
| text | Content inside the Ribbon | ReactNode | - | × |
Semantic DOM
Badge
| Semantic node | Native description | Version |
|---|---|---|
root | Root element with relative positioning, inline-block display, and fit-content width for basic layout | 5.7.0 |
indicator | Indicator element with positioning, z-index, dimensions, colors, fonts, text alignment, background, border-radius, box-shadow, and transition animations for complete badge styling | 5.7.0 |
Semantic description source: vendor/components/badge/demo/_semantic.tsx
Badge.Ribbon
| Semantic node | Native description | Version |
|---|---|---|
root | Root element, set relative positioning and wrapper container styles | 6.0.0 |
indicator | Indicator element, set absolute positioning, padding, background color, border radius and ribbon styles | 6.0.0 |
content | Content element, set text color and ribbon content display styles | 6.0.0 |
Semantic description source: vendor/components/badge/demo/_semantic_ribbon.tsx
Design Token
Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.
| Token | Type | Native description |
|---|---|---|
indicatorZIndex | number | string | z-index of badge |
indicatorHeight | number | string | Height of badge |
indicatorHeightSM | number | string | Height of small badge |
dotSize | number | Size of dot badge |
textFontSize | number | Font size of badge text |
textFontSizeSM | number | Font size of small badge text |
textFontWeight | number | string | Font weight of badge text |
statusSize | number | Size of status badge |
paddingInline | number | string | Inline padding of multiple words badge |
Declaration source: vendor/components/badge/style/index.ts
import type { CSSObject } from '@ant-design/cssinjs';
import { Keyframes, unit } from '@ant-design/cssinjs';
import { resetComponent } from '../../style';
import type { FullToken, GenerateStyle, GenStyleFn, GetDefaultToken } from '../../theme/internal';
import { genPresetColor, genStyleHooks, mergeToken } from '../../theme/internal';
/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {
// Component token here
/**
* @desc 徽标 z-index
* @descEN z-index of badge
*/
indicatorZIndex: number | string;
/**
* @desc 徽标高度
* @descEN Height of badge
*/
indicatorHeight: number | string;
/**
* @desc 小号徽标高度
* @descEN Height of small badge
*/
indicatorHeightSM: number | string;
/**
* @desc 点状徽标尺寸
* @descEN Size of dot badge
*/
dotSize: number;
/**
* @desc 徽标文本尺寸
* @descEN Font size of badge text
*/
textFontSize: number;
/**
* @desc 小号徽标文本尺寸
* @descEN Font size of small badge text
*/
textFontSizeSM: number;
/**
* @desc 徽标文本粗细
* @descEN Font weight of badge text
*/
textFontWeight: number | string;
/**
* @desc 状态徽标尺寸
* @descEN Size of status badge
*/
statusSize: number;
/**
* @desc 多字符徽标水平内边距
* @descEN Inline padding of multiple words badge
*/
paddingInline: number | string;
}
/**
* @desc Badge 组件的 Token
* @descEN Token for Badge component
*/
export interface BadgeToken extends FullToken<'Badge'> {
/**
* @desc 徽标字体高度
* @descEN Font height of badge
*/
badgeFontHeight: number;
/**
* @desc 徽标文本颜色
* @descEN Text color of badge
*/
badgeTextColor: string;
/**
* @desc 徽标颜色
* @descEN Color of badge
*/
badgeColor: string;
/**
* @desc 徽标悬停颜色
* @descEN Hover color of badge
*/
badgeColorHover: string;
/**
* @desc 徽标阴影尺寸
* @descEN Shadow size of badge
*/
badgeShadowSize: number;
/**
* @desc 徽标阴影颜色
* @descEN Shadow color of badge
*/
badgeShadowColor: string;
/**
* @desc 徽标处理持续时间
* @descEN Processing duration of badge
*/
badgeProcessingDuration: string;
/**
* @desc 徽标丝带偏移量
* @descEN Ribbon offset of badge
*/
badgeRibbonOffset: number;
/**
* @desc 徽标丝带角变换
* @descEN Ribbon corner transform of badge
*/
badgeRibbonCornerTransform: string;
/**
* @desc 徽标丝带角滤镜
* @descEN Ribbon corner filter of badge
*/
badgeRibbonCornerFilter: string;
}
Shared native props
Tips: The following generic properties apply to most antd components; those not supported are described separately.
| Property | Description | Type | Default |
|---|---|---|---|
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |
Install and reproduce an example
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.
Native type references
The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.
vendor/components/badge/Badge.tsxvendor/components/badge/Ribbon.tsxvendor/components/badge/ScrollNumber.tsxvendor/components/badge/SingleNumber.tsxvendor/components/badge/index.tsxvendor/components/badge/style/index.ts
Source and license
https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd
Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.