Tag tag
introduce
Used to mark keywords and summarize main content.
Code Demo
Basic usage
Control the label color through the type
attribute.
<z-tag type="primary">tag</z-tag>
<z-tag type="success">tag</z-tag>
<z-tag type="danger">tag</z-tag>
<z-tag type="warning">tag</z-tag>
Closeable tags
Adding the closeable
attribute indicates that the label can be closed. When the label is closed, the close
event will be triggered. In the close
event, the logic of hiding the label can be executed.
<z-tag :show="show" closeable size="medium" type="primary" @close="close">
Label
</z-tag>
import { ref } from 'vue';
const show = ref(true);
const close = () => {
show.value = false;
};
Label size
Resize the label via the size
attribute.
<z-tag type="primary">tag</z-tag>
<z-tag type="primary" size="medium">tag</z-tag>
<z-tag type="primary" size="large">tag</z-tag>
Custom color
Set the label color via the color
and text-color
properties.
<z-tag color="#7232dd">tag</z-tag>
<z-tag color="#ffe1e1" text-color="#ad0000">tag</z-tag>
<z-tag color="#7232dd" plain>tag</z-tag>
API
Props
Parameters | Description | Type | Default value |
---|---|---|---|
type | Type, optional values are primary success danger warning | string | default |
size | Size, optional values are large medium | string | - |
color | label color | string | - |
show | Whether to display tags | boolean | true |
plain | Whether it is hollow style | boolean | false |
round | Whether it is rounded corner style | boolean | false |
mark | Whether it is mark style | boolean | false |
text-color | Text color, has higher priority than color attribute | string | white |
closeable | Whether the tag is closeable | boolean | false |
Slots
Name | Description |
---|---|
default | Label display content |
Events
Event name | Description | Callback parameters |
---|---|---|
click | Triggered when clicked | event: MouseEvent |
close | Triggered when the tag is closed | event: MouseEvent |
Theme customization
Style variables
The component provides the following CSS variables, which can be used to customize styles. For usage, please refer to ConfigProvider component.
Name | Default | Description |
---|---|---|
--z-tag-padding | 0 var(--z-padding-base) | - |
--z-tag-text-color | var(--z-white) | - |
--z-tag-font-size | var(--z-font-size-sm) | - |
--z-tag-radius | 4rpx | - |
--z-tag-line-height | 32rpx | - |
--z-tag-medium-padding | 4rpx 12rpx | - |
--z-tag-large-padding | var(--z-padding-base) var(--z-padding-xs) | - |
--z-tag-large-radius | var(--z-radius-md) | - |
--z-tag-large-font-size | var(--z-font-size-md) | - |
--z-tag-round-radius | var(--z-radius-max) | - |
--z-tag-danger-color | var(--z-danger-color) | - |
--z-tag-primary-color | var(--z-primary-color) | - |
--z-tag-success-color | var(--z-success-color) | - |
--z-tag-warning-color | var(--z-warning-color) | - |
--z-tag-default-color | var(--z-gray-6) | - |
--z-tag-plain-background | var(--z-background-2) | - |