JGuang

Badge

Badge · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Badge

Badge normally appears in the upper right corner of the icon or text to prompt important information.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Basic usage. Just specify count to display the badge.
  • Standalone: Used in standalone when children is empty.
  • Red Badge: A red dot will be displayed instead of the count when dot=true. If count equals 0, the dot will be hidden.
  • Text: Customize the content.
  • Max Count: If the count is larger than maxCount, ${maxCount}+ will be displayed. The default value of maxCount is 99.
  • Status: A variety of status are available: default, processing, success, warning and error.
  • Color: We provide a variety of preset colors for the badge. You can also set a custom color with color property.
  • Animated: The count will be animated as it changes.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Badge

PropertyDescriptionTypeDefaultValue
dotWhether to display a red dot instead of countboolean-
maxCountMax count to show. If count is larger than this value, it will be displayed as ${maxCount}+number99
textSet the display text of the status dotstring-
colorCustomize dot color| 'red'| 'orangered'| 'orange'| 'gold'| 'lime'| 'green'| 'cyan'| 'arcoblue'| 'purple'| 'pinkpurple'| 'magenta'| 'gray'| string-
statusSet badge as a status dot'default' | 'processing' | 'success' | 'warning' | 'error'-
countNumber to show in badgenumber | ReactNode0
classNameAdditional css classstring | string[]-
dotClassNameCustomize Badge dot classNamestring | string[]-
dotStyleCustomize Badge dot styleCSSProperties-
offsetSet offset of the badge dot[number, number]-
styleAdditional styleCSSProperties-

Questions

  1. How to hide the red dot when dot=true? You can set count=0. The logo will be displayed only when count> 0.