Used for marking and selection.
::: demo Use the type
attribute to define Tag's type.
<el-tag>Tag One</el-tag>
<el-tag type="gray">Tag Two</el-tag>
<el-tag type="primary">Tag Three</el-tag>
<el-tag type="success">Tag Four</el-tag>
<el-tag type="warning">Tag Five</el-tag>
<el-tag type="danger">Tag Six</el-tag>
:::
:::demo Set the closable
attribute to define a removable tag. It accepts a Boolean
. By default the removal of Tag has a fading animation. If you don't want to use it, you can set the close-transition
attribute, which accepts a Boolean
, to true
. close
event triggers when Tag is removed.
<el-tag
v-for="tag in tags"
:closable="true"
:type="tag.type"
:key="tag"
:close-transition="false"
@close="handleClose(tag)"
>
{{tag.name}}
</el-tag>
<script>
export default {
data() {
return {
tags: [
{ key: 1, name: 'Tag One', type: '' },
{ key: 2, name: 'Tag Two', type: 'gray' },
{ key: 5, name: 'Tag Three', type: 'primary' },
{ key: 3, name: 'Tag Four', type: 'success' },
{ key: 4, name: 'Tag Five', type: 'warning' },
{ key: 6, name: 'Tag Six', type: 'danger' }
]
};
},
methods: {
handleClose(tag) {
this.tags.splice(this.tags.indexOf(tag), 1);
}
}
}
</script>
:::
Attribute | Description | Type | Accepted Values | Default |
---|---|---|---|---|
type | theme | string | primary/gray/success/warning/danger | — |
closable | whether Tab can be removed | boolean | — | false |
close-transition | whether the removal animation is disabled | boolean | — | false |
hit | whether Tag has a highlighted border | boolean | — | false |
Event Name | Description | Parameters |
---|---|---|
close | triggers when Tab is removed | — |