Back to Ant Design

Badge

components/badge/index.en-US.md

6.4.43.7 KB
Original Source

When To Use

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

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/no-wrapper.tsx">Standalone</code> <code src="./demo/overflow.tsx">Overflow Count</code> <code src="./demo/dot.tsx">Red badge</code> <code src="./demo/change.tsx">Dynamic</code> <code src="./demo/link.tsx">Clickable</code> <code src="./demo/offset.tsx">Offset</code> <code src="./demo/size.tsx">Size</code> <code src="./demo/status.tsx">Status</code> <code src="./demo/colorful.tsx">Colorful Badge</code> <code src="./demo/ribbon.tsx">Ribbon</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code> <code src="./demo/ribbon-debug.tsx" debug>Ribbon Debug</code> <code src="./demo/mix.tsx" debug>Mixed usage</code> <code src="./demo/title.tsx" debug>Title</code> <code src="./demo/colorful-with-count-debug.tsx" debug>Colorful Badge support count Debug</code> <code src="./demo/component-token.tsx" debug>Component Token</code>

API

Common props ref:Common props

Badge

PropertyDescriptionTypeDefaultVersionGlobal Config
colorCustomize Badge dot colorstring-×
countNumber to show in badgeReactNode-×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<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 badgemedium | small--×
statusSet Badge as a status dotsuccess | processing | default | error | warning-×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<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

PropertyDescriptionTypeDefaultVersionGlobal Config
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-6.0.0
colorCustomize Ribbon colorstring-×
placementThe placement of the Ribbon, start and end follow text direction (RTL or LTR)start | endend×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-6.0.0
textContent inside the RibbonReactNode-×

Semantic DOM

Badge

<code src="./demo/_semantic.tsx" simplify="true"></code>

Badge.Ribbon

<code src="./demo/_semantic_ribbon.tsx" simplify="true"></code>

Design Token

<ComponentTokenTable component="Badge"></ComponentTokenTable>