doc.en-US.md 3.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
# Tag

### Intro

Labels for tagging and classification.

### Install

```javascript

import { createApp } from 'vue';
// vue
import { Tag } from '@nutui/nutui';
// taro
import { Tag } from '@nutui/nutui-taro';

const app = createApp();
app.use(Tag);

```

### Basic Usage

:::demo
```html
<template>
 <nut-cell-group title="Basic Usage">
    <nut-cell title="primary">
      <template v-slot:link>
        <nut-tag type="primary">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="success">
      <template v-slot:link>
        <nut-tag type="success">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="danger">
      <template v-slot:link>
        <nut-tag type="danger">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="warning">
      <template v-slot:link>
        <nut-tag type="warning">Tag</nut-tag>
      </template>
    </nut-cell>
  </nut-cell-group>
</template>

```
:::

### Style 

:::demo
```html
<template>
  <nut-cell-group title="Style">
    <nut-cell title="plain">
      <template v-slot:link>
        <nut-tag plain>Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="round">
      <template v-slot:link>
        <nut-tag round type="primary">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="mark">
      <template v-slot:link>
        <nut-tag mark type="primary">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="closeable">
      <template v-slot:link>
        <nut-tag v-if="show" closeable @close="close" type="primary">Tag</nut-tag>
      </template>
    </nut-cell>
  </nut-cell-group>
</template>


<script lang="ts">
import { ref } from 'vue';

export default {
  setup() {
    const show = ref(true);
    const close = () => {
      show.value = false;
    };

    return {
      close,
      show
    };
  }
};
</script>



```
:::


### Custom Color

:::demo
```html
<template>
  <nut-cell-group title="Custom Color">
    <nut-cell title="background color">
      <template v-slot:link>
        <nut-tag color="#FA685D">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="text color">
      <template v-slot:link>
        <nut-tag color="#E9E9E9" textColor="#999999">Tag</nut-tag>
      </template>
    </nut-cell>
    <nut-cell title="plain color">
      <template v-slot:link>
        <nut-tag color="#FA2400" plain>Tag</nut-tag>
      </template>
    </nut-cell>
  </nut-cell-group>
</template>

```
:::



137
### Props  
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

| Attribute | Description | Type | Default |
|------------|--------------------------------------------------|---------|-----------|
| type       | Label type,can be set `primary` `success` `danger` `warning` | String  | `default` |
| color      | Label color                                         | String  | -         |
| text-color | Text color, which takes precedence over the color attribute| String  | `white`   |
| plain      | Whether it is plain | Boolean | `false`   |
| round      | Whether it is round                                   | Boolean | `false`   |
| mark       | Whether it is mark                                   | Boolean | `false`   |
| closeable  | Whether it is a closeable tag       | Boolean | `false`   |


### Slots

| Name   | Description           |
|---------|--------------|
| default | Label display content |

156
### Events
157 158 159 160 161

| Event             | Description                     | Arguments        |
|----------|----------|----------|
| click    | click event | event    |
| close    | close event | event    |