2016-07-11 11:45:42 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
|
title: Badge
|
2022-11-30 20:14:41 +08:00
|
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*e0qITYqF394AAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*v8EQT7KoGbcAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
|
demo:
|
|
|
|
|
cols: 2
|
|
|
|
|
group: Data Display
|
2016-07-11 11:45:42 +08:00
|
|
|
|
---
|
|
|
|
|
|
2017-09-16 11:29:38 +08:00
|
|
|
|
Small numerical value or status descriptor for UI elements.
|
2016-07-11 11:45:42 +08:00
|
|
|
|
|
2016-09-10 13:43:30 +08:00
|
|
|
|
## When To Use
|
2016-07-11 11:45:42 +08:00
|
|
|
|
|
2017-09-16 11:29:38 +08:00
|
|
|
|
Badge normally appears in proximity to notifications or user avatars with eye-catching appeal, typically displaying unread messages count.
|
2016-07-11 11:45:42 +08:00
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## Examples
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<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>
|
2022-11-21 18:18:04 +08:00
|
|
|
|
<code src="./demo/ribbon.tsx">Ribbon</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<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>
|
2023-08-14 17:18:42 +08:00
|
|
|
|
<code src="./demo/component-token.tsx" debug>Component Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2016-07-11 11:45:42 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
Common props ref:[Common props](/docs/react/common-props)
|
|
|
|
|
|
2020-07-08 14:47:07 +08:00
|
|
|
|
### Badge
|
|
|
|
|
|
2019-03-31 20:21:20 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
2023-08-15 09:31:49 +08:00
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| color | Customize Badge dot color | string | - | |
|
|
|
|
|
| count | Number to show in badge | ReactNode | - | |
|
|
|
|
|
| classNames | Semantic DOM class | 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 | |
|
2023-08-27 23:48:56 +08:00
|
|
|
|
| size | If `count` is set, `size` sets the size of badge | `default` \| `small` | - | - |
|
2023-08-15 09:31:49 +08:00
|
|
|
|
| status | Set Badge as a status dot | `success` \| `processing` \| `default` \| `error` \| `warning` | - | |
|
|
|
|
|
| styles | Semantic DOM style | 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 | string | - | |
|
2020-07-08 14:47:07 +08:00
|
|
|
|
|
2023-08-27 23:48:56 +08:00
|
|
|
|
### Badge.Ribbon
|
2020-07-08 14:47:07 +08:00
|
|
|
|
|
2021-02-28 09:09:48 +08:00
|
|
|
|
| Property | Description | Type | Default | Version |
|
2020-07-08 14:47:07 +08:00
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| color | Customize Ribbon color | string | - | |
|
|
|
|
|
| placement | The placement of the Ribbon, `start` and `end` follow text direction (RTL or LTR) | `start` \| `end` | `end` | |
|
|
|
|
|
| text | Content inside the Ribbon | ReactNode | - | |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2023-06-29 10:40:56 +08:00
|
|
|
|
### `styles` and `classNames` attribute
|
|
|
|
|
|
|
|
|
|
| Property | Description | Version |
|
|
|
|
|
| --------- | ------------------- | ------- |
|
|
|
|
|
| root | set `root` element | 5.7.0 |
|
|
|
|
|
| indicator | set `badge` element | 5.7.0 |
|
|
|
|
|
|
2023-04-11 10:25:24 +08:00
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Badge"></ComponentTokenTable>
|