JGuang

Badge

Badge · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Badge

Display numbers, text, and small red dots in the upper right corner.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Display numbers, text, and small red dots in the upper right corner.

When to Use

It is suitable for reminders of productized new news, new functions, new services, etc., and attracts users to deal with it through eye-catching visual forms.

Demos

Badge

Props

NameDescriptionTypeDefault
borderedWhether to have border.booleanfalse
colorThe background color of the Badge. Equivalent to setting the --color CSS variable.string-
contentThe content of the Badge: if null undefined '' or nothing is passed, it would not be displayed; if Badge.dot is passed, a small red dot would be displayedReact.ReactNode | typeof Badge.dot-
wrapperClassNameBadge wrap class namestring-
wrapperStyleBadge wrap styleReact.CSSProperties-

CSS Variables

NameDescriptionDefaultGlobal
--colorThe background color of the Badgevar(--adm-color-highlight)--adm-badge-color
--rightThe offset to the left, relative to the far right0-
--topThe downward offset, relative to the uppermost edge0-