# @ophiuchus/tag

> ### 引入

Latest version **1.0.1** (published 2021-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ophiuchus/tag
pnpm add @ophiuchus/tag
yarn add @ophiuchus/tag
bun add @ophiuchus/tag
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-09-26 |
| First published | 2021-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | songbug1024 |
| Maintainers | songbug1024 |
| Keywords | ui, vue, frontend, component, ophiuchus, vant, vite |

## Links

- npm: https://www.npmjs.com/package/@ophiuchus/tag
- Homepage: https://github.com/songbug1024/ophiuchus
- Issues: https://github.com/songbug1024/ophiuchus/issues
- npm.io page: https://npm.io/package/@ophiuchus/tag

## Dependencies (1)

- [@ophiuchus/icon](https://npm.io/package/@ophiuchus/icon.md) ^1.0.2

## Alternatives

- [@progress/kendo-ooxml](https://npm.io/package/@progress/kendo-ooxml.md) — 152.1K weekly downloads
- [@progress/kendo-react-ripple](https://npm.io/package/@progress/kendo-react-ripple.md) — 8.0K weekly downloads
- [@progress/kendo-react-orgchart](https://npm.io/package/@progress/kendo-react-orgchart.md) — 4.3K weekly downloads
- [@praxisui/dynamic-fields](https://npm.io/package/@praxisui/dynamic-fields.md) — 2.4K weekly downloads
- [@progress/kendo-vue-listbox](https://npm.io/package/@progress/kendo-vue-listbox.md) — 932 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-09-26
- 1.0.0 — 2021-09-01

## README

# Tag 标签

### 引入

```js
import Vue from 'vue';
import Tag from '@ophiuchus/tag';

Vue.use(Tag);
```

## 代码演示

### 基础用法

通过 `type` 属性控制标签颜色。

```html
<sf-tag type="primary">标签</sf-tag>
<sf-tag type="success">标签</sf-tag>
<sf-tag type="danger">标签</sf-tag>
<sf-tag type="warning">标签</sf-tag>
```

### 空心样式

设置 `plain` 属性设置为空心样式。

```html
<sf-tag plain type="primary">标签</sf-tag>
```

### 圆角样式

通过 `round` 设置为圆角样式。

```html
<sf-tag round type="primary">标签</sf-tag>
```

### 标记样式

通过 `mark` 设置为标记样式(半圆角)。

```html
<sf-tag mark type="primary">标签</sf-tag>
```

### 可关闭标签

添加 `closeable` 属性表示标签是可关闭的，关闭标签时会触发 `close` 事件，在 `close` 事件中可以执行隐藏标签的逻辑。

```html
<sf-tag v-if="show" closeable size="medium" type="primary" @close="close">
  标签
</sf-tag>
```

```js
export default {
  data() {
    return {
      show: true,
    };
  },
  methods: {
    close() {
      this.show = false;
    },
  },
};
```

### 标签大小

通过 `size` 属性调整标签大小。

```html
<sf-tag type="primary">标签</sf-tag>
<sf-tag type="primary" size="medium">标签</sf-tag>
<sf-tag type="primary" size="large">标签</sf-tag>
```

### 自定义颜色

通过 `color` 和 `text-color` 属性设置标签颜色。

```html
<sf-tag color="#7232dd">标签</sf-tag>
<sf-tag color="#ffe1e1" text-color="#ad0000">标签</sf-tag>
<sf-tag color="#7232dd" plain>标签</sf-tag>
```

## API

### Props

| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| type | 类型，可选值为`primary` `success` `danger` `warning` | _string_ | `default` |
| size | 大小, 可选值为`large` `medium` | _string_ | - |
| color | 标签颜色 | _string_ | - |
| plain | 是否为空心样式 | _boolean_ | `false` |
| round | 是否为圆角样式 | _boolean_ | `false` |
| mark | 是否为标记样式 | _boolean_ | `false` |
| text-color | 文本颜色，优先级高于`color`属性 | _string_ | `white` |
| closeable | 是否为可关闭标签 | _boolean_ | `false` |

### Slots

| 名称    | 说明         |
| ------- | ------------ |
| default | 标签显示内容 |

### Events

| 事件名 | 说明           | 回调参数       |
| ------ | -------------- | -------------- |
| click  | 点击时触发     | _event: Event_ |
| close  | 关闭标签时触发 | -              |

### 样式变量

组件提供了下列 Less 变量，可用于自定义样式，使用方法请参考[主题定制](#/theme)。

| 名称                        | 默认值                      | 描述 |
| --------------------------- | --------------------------- | ---- |
| @tag-padding                | `0 @padding-base`           | -    |
| @tag-text-color             | `@white`                    | -    |
| @tag-font-size              | `@font-size-sm`             | -    |
| @tag-border-radius          | `2px`                       | -    |
| @tag-line-height            | `16px`                      | -    |
| @tag-medium-padding         | `2px 6px`                   | -    |
| @tag-large-padding          | `@padding-base @padding-xs` | -    |
| @tag-large-border-radius    | `@border-radius-md`         | -    |
| @tag-large-font-size        | `@font-size-md`             | -    |
| @tag-round-border-radius    | `@border-radius-max`        | -    |
| @tag-danger-color           | `@red`                      | -    |
| @tag-primary-color          | `@blue`                     | -    |
| @tag-success-color          | `@green`                    | -    |
| @tag-warning-color          | `@orange`                   | -    |
| @tag-default-color          | `@gray-6`                   | -    |
| @tag-plain-background-color | `@white`                    | -    |

---
_Source: https://npm.io/package/@ophiuchus/tag · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
