2016-03-31 14:17:09 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2016-09-21 11:28:38 +08:00
|
|
|
subtitle: 标签
|
2022-11-09 12:28:04 +08:00
|
|
|
group: 数据展示
|
2016-09-21 11:28:38 +08:00
|
|
|
title: Tag
|
2022-11-30 20:14:41 +08:00
|
|
|
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*_SBsSrKLg00AAAAAAAAAAAAADrJ8AQ/original
|
2023-02-09 22:17:31 +08:00
|
|
|
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*JPNAQYrVkYkAAAAAAAAAAAAADrJ8AQ/original
|
2022-11-09 12:28:04 +08:00
|
|
|
demo:
|
|
|
|
cols: 2
|
2016-03-31 14:17:09 +08:00
|
|
|
---
|
2015-07-22 11:06:55 +08:00
|
|
|
|
2015-07-28 20:15:25 +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/colorful.tsx">多彩标签</code>
|
|
|
|
<code src="./demo/colorful-inverse.tsx" debug>反色多彩标签</code>
|
|
|
|
<code src="./demo/control.tsx">动态添加和删除</code>
|
|
|
|
<code src="./demo/checkable.tsx">可选择标签</code>
|
|
|
|
<code src="./demo/animation.tsx">添加动画</code>
|
|
|
|
<code src="./demo/icon.tsx">图标按钮</code>
|
|
|
|
<code src="./demo/status.tsx">预设状态的标签</code>
|
2023-03-21 13:02:27 +08:00
|
|
|
<code src="./demo/borderless.tsx">无边框</code>
|
|
|
|
<code src="./demo/borderlessLayout.tsx" debug>深色背景中无边框</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
<code src="./demo/customize.tsx" debug>自定义关闭按钮</code>
|
2023-04-04 10:05:04 +08:00
|
|
|
<code src="./demo/draggable.tsx">可拖拽标签</code>
|
2023-05-23 09:45:41 +08:00
|
|
|
<code src="./demo/component-token.tsx" debug>组件 Token</code>
|
2022-11-09 12:28:04 +08:00
|
|
|
|
2015-07-28 20:15:25 +08:00
|
|
|
## API
|
|
|
|
|
2023-08-08 18:27:48 +08:00
|
|
|
通用属性参考:[通用属性](/docs/react/common-props)
|
|
|
|
|
2016-11-10 11:14:03 +08:00
|
|
|
### Tag
|
|
|
|
|
2021-03-01 19:20:48 +08:00
|
|
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
|
|
|
| --- | --- | --- | --- | --- |
|
2023-06-20 13:42:55 +08:00
|
|
|
| closeIcon | 自定义关闭按钮。5.7.0:设置为 `null` 或 `false` 时隐藏关闭按钮 | boolean \| ReactNode | false | 4.4.0 |
|
2021-03-01 19:20:48 +08:00
|
|
|
| color | 标签色 | string | - | |
|
|
|
|
| icon | 设置图标 | ReactNode | - | |
|
2023-03-21 13:02:27 +08:00
|
|
|
| bordered | 是否有边框 | boolean | true | 5.4.0 |
|
2021-05-25 15:31:50 +08:00
|
|
|
| onClose | 关闭时的回调(可通过 `e.preventDefault()` 来阻止默认行为) | (e) => void | - | |
|
2016-11-10 11:14:03 +08:00
|
|
|
|
|
|
|
### Tag.CheckableTag
|
|
|
|
|
2022-08-15 14:39:02 +08:00
|
|
|
| 参数 | 说明 | 类型 | 默认值 |
|
|
|
|
| -------- | -------------------- | ----------------- | ------ |
|
|
|
|
| checked | 设置标签的选中状态 | boolean | false |
|
|
|
|
| onChange | 点击标签时触发的回调 | (checked) => void | - |
|
2023-04-11 10:25:24 +08:00
|
|
|
|
|
|
|
## Design Token
|
|
|
|
|
|
|
|
<ComponentTokenTable component="Tag"></ComponentTokenTable>
|