Skip to content

Tag

Used to mark status or summarize main content.

Component Types

Basic Usage

Set different tag types through type.

html
<wd-tag>Tag</wd-tag>
<wd-tag type="primary">Common Tag</wd-tag>
<wd-tag type="danger">Danger Tag</wd-tag>
<wd-tag type="warning">Warning Tag</wd-tag>
<wd-tag type="success">Success Tag</wd-tag>

Component Variants

Tag Size

Set tag size through size, supports small, medium, default, large, extra-large.

html
<wd-tag type="primary" size="small">Small Tag</wd-tag>
<wd-tag type="primary" size="medium">Medium Tag</wd-tag>
<wd-tag type="primary">Default Tag</wd-tag>
<wd-tag type="primary" size="large">Large Tag</wd-tag>
<wd-tag type="primary" size="extra-large">Extra Large Tag</wd-tag>

Light Tag

Setting variant="light" displays a light-colored tag.

html
<wd-tag variant="light">Tag</wd-tag>
<wd-tag type="primary" variant="light">Common Tag</wd-tag>
<wd-tag type="danger" variant="light">Danger Tag</wd-tag>

Plain Tag

Setting variant="plain" displays a plain style.

html
<wd-tag variant="plain">Tag</wd-tag>
<wd-tag type="primary" variant="plain">Common Tag</wd-tag>

Dashed Tag

Setting variant="dashed" displays a dashed border.

html
<wd-tag variant="dashed">Tag</wd-tag>
<wd-tag type="warning" variant="dashed">Warning Tag</wd-tag>

Text Tag

Setting variant="text" displays a plain text style.

html
<wd-tag variant="text">Tag</wd-tag>
<wd-tag type="success" variant="text">Success Tag</wd-tag>

Component Styles

Mark Tag

Setting mark generates a mark style.

html
<wd-tag mark>Tag</wd-tag>
<wd-tag type="primary" mark>Common Tag</wd-tag>

Ghost Mark Tag

Combining mark and variant="plain" displays a ghost mark style.

html
<wd-tag mark variant="plain">Tag</wd-tag>
<wd-tag type="success" mark variant="plain">Success Tag</wd-tag>

Round Tag

Setting round generates a round style.

html
<wd-tag round>Tag</wd-tag>
<wd-tag type="primary" round>Common Tag</wd-tag>

Set Icon

You can customize the left icon through the icon property or icon slot.

html
<wd-tag icon="clock-circle" type="primary" mark>Tag</wd-tag>

<wd-tag type="primary" mark>
  <text>Slot</text>
  <template #icon>
    <wd-icon name="thunderbolt" />
  </template>
</wd-tag>

Custom Color

Set text color through color, and set background color and border color through bg-color.

html
<wd-tag color="#0083ff" bg-color="#d0e8ff">Tag</wd-tag>
<wd-tag color="#FAA21E" bg-color="#FAA21E" variant="plain">Tag</wd-tag>

Special Styles

Closable

After setting closable, clicking the close button will trigger the close event.

html
<wd-tag v-for="(tag, index) in closableStrongTags" :key="index" :type="tag.type" closable @close="handleCloseStrongTag(index)">
  {{ tag.value }}
</wd-tag>
ts
const closableStrongTags = ref([
  { type: 'default', value: 'Tag' },
  { type: 'primary', value: 'Common' }
])

function handleCloseStrongTag(order: number) {
  closableStrongTags.value = closableStrongTags.value.filter((_, index) => index !== order)
}

Add Tag

Setting dynamic generates an add tag style. After input confirmation, the confirm event is triggered. You can customize the add button content through the add slot.

html
<wd-tag v-for="(tag, index) in dynamicTags" :key="index" type="primary" closable @close="handleClose1(index)">
  {{ tag }}
</wd-tag>
<wd-tag type="primary" dynamic @confirm="handleConfirm"></wd-tag>
<wd-tag type="primary" dynamic @confirm="handleConfirm">
  <template #add>
    <wd-icon name="pushpin" size="12px"></wd-icon>
    <text style="margin-left: 4px">Custom</text>
  </template>
</wd-tag>
ts
const dynamicTags = ref(['Tag One', 'Tag Two'])

function handleClose1(order: number) {
  dynamicTags.value = dynamicTags.value.filter((item, index) => index !== order)
}

function handleConfirm({ value }: { value: string }) {
  if (!value) return
  dynamicTags.value = [...dynamicTags.value, value]
}

Attributes

ParameterDescriptionTypeDefault Value
sizeTag size, optional values are small, medium, large, extra-large, defaultTagSizedefault
typeTag type, optional values are default, primary, success, warning, danger, volcano, lightblue, cyan, pink, purpleTagTypedefault
iconLeft iconstring''
closableWhether closablebooleanfalse
dynamicWhether it is an add tagbooleanfalse
colorText colorstring''
bg-colorBackground color and border colorstring''
roundWhether roundbooleanfalse
markWhether mark stylebooleanfalse
variantTag variant, optional values are light, dark, plain, dashed, textTagVariantdark
custom-classRoot node custom class namestring''
custom-styleRoot node custom stylestring''

Events

Event NameDescriptionParameters
clickTriggered when clicking tagMouseEvent
closeTriggered when clicking close buttonMouseEvent
confirmTriggered after add tag input confirmation{ value: string }

Slots

NameDescription
defaultTag content
iconCustom icon
addCustom add tag content, effective when dynamic is true

External Style Classes

Class NameDescription
custom-classRoot node style class
custom-styleRoot node inline style

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-tag-color$text-white基础文字颜色
--wot-tag-font-size$typography-label-size-main基础字号
--wot-tag-radius$radius-small默认圆角
--wot-tag-round-radius$radius-radius-full圆角标签圆角
--wot-tag-mark-radius$radius-large $radius-main标记标签圆角
--wot-tag-icon-spacing$spacing-ultra-tight图标间距
--wot-tag-input-width$n-64输入态宽度
--wot-tag-primary-light-bg$primary-1主色浅色背景
--wot-tag-primary-bg$primary-6主色背景
--wot-tag-primary-color$primary-6主色文字颜色
--wot-tag-success-bg$success-main成功色背景
--wot-tag-success-light-bg$success-surface成功色浅色背景
--wot-tag-success-color$success-main成功色文字颜色
--wot-tag-warning-bg$warning-main警告色背景
--wot-tag-warning-light-bg$warning-surface警告色浅色背景
--wot-tag-warning-color$warning-main警告色文字颜色
--wot-tag-danger-bg$danger-main危险色背景
--wot-tag-danger-light-bg$danger-surface危险色浅色背景
--wot-tag-danger-color$danger-main危险色文字颜色
--wot-tag-volcano-bg$volcano-6橘火色背景
--wot-tag-volcano-light-bg$volcano-1橘火色浅色背景
--wot-tag-volcano-color$volcano-6橘火色文字颜色
--wot-tag-info-bg$text-auxiliary默认信息色背景
--wot-tag-info-light-bg$filled-content默认信息色浅色背景
--wot-tag-info-color$text-secondary默认信息色文字颜色
--wot-tag-lightblue-bg$lightblue-6亮蓝色背景
--wot-tag-lightblue-light-bg$lightblue-1亮蓝色浅色背景
--wot-tag-lightblue-color$lightblue-6亮蓝色文字颜色
--wot-tag-cyan-bg$cyan-6青色背景
--wot-tag-cyan-light-bg$cyan-1青色浅色背景
--wot-tag-cyan-color$cyan-6青色文字颜色
--wot-tag-pink-bg$pink-6粉色背景
--wot-tag-pink-light-bg$pink-1粉色浅色背景
--wot-tag-pink-color$pink-6粉色文字颜色
--wot-tag-purple-bg$purple-6紫色背景
--wot-tag-purple-light-bg$purple-1紫色浅色背景
--wot-tag-purple-color$purple-6紫色文字颜色
--wot-tag-small-font-size$typography-label-size-small小尺寸字号
--wot-tag-small-line-height$typography-label-line--height-size-small小尺寸行高
--wot-tag-small-padding$padding-zero $padding-super-tight小尺寸内边距
--wot-tag-small-round-padding$padding-zero $padding-tight小尺寸圆角态内边距
--wot-tag-small-icon-size$n-10小尺寸图标尺寸
--wot-tag-medium-font-size$typography-label-size-main中尺寸字号
--wot-tag-medium-line-height$typography-label-line--height-size-main中尺寸行高
--wot-tag-medium-padding$n-1 $padding-super-tight中尺寸内边距
--wot-tag-medium-round-padding$n-1 $padding-tight中尺寸圆角态内边距
--wot-tag-medium-icon-size$n-10中尺寸图标尺寸
--wot-tag-default-font-size$typography-label-size-main默认尺寸字号
--wot-tag-default-line-height$typography-label-line--height-size-main默认尺寸行高
--wot-tag-default-padding$n-3 $padding-extra-tight默认尺寸内边距
--wot-tag-default-round-padding$n-3 $padding-loose默认尺寸圆角态内边距
--wot-tag-default-icon-size$n-12默认尺寸图标尺寸
--wot-tag-large-font-size$typography-label-size-large大尺寸字号
--wot-tag-large-line-height$typography-label-line--height-size-large大尺寸行高
--wot-tag-large-padding$n-3 $padding-extra-tight大尺寸内边距
--wot-tag-large-round-padding$n-3 $padding-loose大尺寸圆角态内边距
--wot-tag-large-icon-size$n-12大尺寸图标尺寸
--wot-tag-extra-large-font-size$typography-body-size-main超大尺寸字号
--wot-tag-extra-large-line-height$typography-body-line--height-size-main超大尺寸行高
--wot-tag-extra-large-padding$n-3 $padding-extra-tight超大尺寸内边距
--wot-tag-extra-large-round-padding$n-3 $padding-loose超大尺寸圆角态内边距
--wot-tag-extra-large-icon-size$n-12超大尺寸图标尺寸

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.