---
url: /reference/interface/ui-components/tag.md
---
# Tag

标签用于标记和分类，可展示状态、属性或关键词。

## 使用

::: code-group

```ts [Angular]
import { NxTag, NxTags } from "@pc-nexus/angular";
```

```ts [React]
import { NxTag, NxTags } from "@pc-nexus/react";
```

:::

## 属性

:::comp-props

| 名称         | 类型                                                                               | 必填 | 描述                           |
| ------------ | ---------------------------------------------------------------------------------- | ---- | ------------------------------ |
| `color`      | `'default' \| 'primary' \| 'success' \| 'info' \| 'warning' \| 'danger' \| string` |      | 标签颜色，默认 `default`       |
| `appearance` | `'fill' \| 'outline' \| 'subtle'`                                                  |      | 标签外观，默认 `fill`          |
| `size`       | `'small' \| 'medium' \| 'large'`                                                   |      | 尺寸，默认 `medium`            |
| `shape`      | `'ellipse' \| 'rectangle'`                                                         |      | 标签形状，默认 `rectangle`     |
| `hoverable`  | `boolean`                                                                          |      | 是否启用悬停效果，默认 `false` |

:::

## 示例

### Basic

:::demo src=tag-basic
:::

### Color

通过 `color` 设置语义色或自定义色值。

:::demo src=tag-color
:::

### Appearance

通过 `appearance` 设置外观，取值可以为 `'fill' | 'outline' | 'subtle'`。

:::demo src=tag-appearance
:::

### Shape

通过 `shape` 设置形状，取值可以为 `'ellipse' | 'rectangle'`

:::demo src=tag-shape
:::

### Size

:::demo src=tag-size
:::

### Hoverable

:::demo src=tag-hoverable
:::

### With icon

标签内容可嵌套 `nx-icon` 等子节点。

:::demo src=tag-with-icon
:::

### Dynamic

:::demo src=tag-dynamic
:::

### Tags

使用 `nx-tags` 包裹多个 `nx-tag`。

:::demo src=tag-tags
:::
