2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
|
title: Badge
|
2024-03-22 14:22:42 +08:00
|
|
|
|
subtitle: 徽标数
|
|
|
|
|
description: 图标右上角的圆形徽标数字。
|
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: 数据展示
|
2016-03-31 14:17:09 +08:00
|
|
|
|
---
|
2015-09-01 13:59:07 +08:00
|
|
|
|
|
|
|
|
|
## 何时使用
|
|
|
|
|
|
2015-09-01 17:16:51 +08:00
|
|
|
|
一般出现在通知图标或头像的右上角,用于显示需要处理的消息条数,通过醒目视觉形式吸引用户处理。
|
2015-09-01 13:59:07 +08:00
|
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
|
## 代码演示
|
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
|
<code src="./demo/basic.tsx">基本</code>
|
|
|
|
|
<code src="./demo/no-wrapper.tsx">独立使用</code>
|
|
|
|
|
<code src="./demo/overflow.tsx">封顶数字</code>
|
|
|
|
|
<code src="./demo/dot.tsx">讨嫌的小红点</code>
|
|
|
|
|
<code src="./demo/change.tsx">动态</code>
|
|
|
|
|
<code src="./demo/link.tsx">可点击</code>
|
|
|
|
|
<code src="./demo/offset.tsx">自定义位置偏移</code>
|
|
|
|
|
<code src="./demo/size.tsx">大小</code>
|
|
|
|
|
<code src="./demo/status.tsx">状态点</code>
|
|
|
|
|
<code src="./demo/colorful.tsx">多彩徽标</code>
|
2022-11-21 18:18:04 +08:00
|
|
|
|
<code src="./demo/ribbon.tsx">缎带</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>各种混用的情况</code>
|
|
|
|
|
<code src="./demo/title.tsx" debug>自定义标题</code>
|
|
|
|
|
<code src="./demo/colorful-with-count-debug.tsx" debug>多彩徽标支持 count 显示 Debug</code>
|
2023-08-14 17:18:42 +08:00
|
|
|
|
<code src="./demo/component-token.tsx" debug>组件 Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
|
2015-09-01 13:59:07 +08:00
|
|
|
|
## API
|
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
|
2020-07-08 14:47:07 +08:00
|
|
|
|
### Badge
|
|
|
|
|
|
2019-03-31 20:21:20 +08:00
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
2019-11-20 20:31:43 +08:00
|
|
|
|
| color | 自定义小圆点的颜色 | string | - | |
|
2020-07-01 21:35:29 +08:00
|
|
|
|
| count | 展示的数字,大于 overflowCount 时显示为 `${overflowCount}+`,为 0 时隐藏 | ReactNode | - | |
|
2024-02-05 11:45:42 +08:00
|
|
|
|
| classNames | 语义化结构 class | [Record<SemanticDOM, string>](#semantic-dom) | - | 5.7.0 |
|
2019-05-07 14:57:32 +08:00
|
|
|
|
| dot | 不展示数字,只有一个小红点 | boolean | false | |
|
2020-07-01 21:35:29 +08:00
|
|
|
|
| offset | 设置状态点的位置偏移 | \[number, number] | - | |
|
2019-05-07 14:57:32 +08:00
|
|
|
|
| overflowCount | 展示封顶的数字值 | number | 99 | |
|
|
|
|
|
| showZero | 当数值为 0 时,是否展示 Badge | boolean | false | |
|
2023-08-27 23:48:56 +08:00
|
|
|
|
| size | 在设置了 `count` 的前提下有效,设置小圆点的大小 | `default` \| `small` | - | - |
|
2020-10-21 10:33:43 +08:00
|
|
|
|
| status | 设置 Badge 为状态点 | `success` \| `processing` \| `default` \| `error` \| `warning` | - | |
|
2024-02-05 11:45:42 +08:00
|
|
|
|
| styles | 语义化结构 style | [Record<SemanticDOM, CSSProperties>](#semantic-dom) | - | 5.7.0 |
|
2020-07-08 14:47:07 +08:00
|
|
|
|
| text | 在设置了 `status` 的前提下有效,设置状态点的文本 | ReactNode | - | |
|
2020-07-01 21:35:29 +08:00
|
|
|
|
| title | 设置鼠标放在状态点上时显示的文字 | 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
|
|
|
|
|
|
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
|
| color | 自定义缎带的颜色 | string | - | |
|
|
|
|
|
| placement | 缎带的位置,`start` 和 `end` 随文字方向(RTL 或 LTR)变动 | `start` \| `end` | `end` | |
|
|
|
|
|
| text | 缎带中填入的内容 | ReactNode | - | |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
2024-02-05 11:45:42 +08:00
|
|
|
|
## Semantic DOM
|
2023-06-29 10:40:56 +08:00
|
|
|
|
|
2024-02-05 11:45:42 +08:00
|
|
|
|
<code src="./demo/_semantic.tsx" simplify="true"></code>
|
2023-06-29 10:40:56 +08:00
|
|
|
|
|
2023-08-30 23:02:35 +08:00
|
|
|
|
## 主题变量(Design Token)
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Badge"></ComponentTokenTable>
|