Skip to content

Tag Component ​

The tag component is generally used for marking and selection. We provide richer presentation styles to comprehensively cover your usage scenarios.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Example ​

html
<!-- Global usage -->
<hy-tag label="Tag"></hy-tag>

Theme Colors ​

  • Configure the theme color by setting type
    • primary: Info tag (default)
    • success: Main tag
    • info: Default tag
    • warning: Warning tag
    • error: Danger tag
  • Set custom colors or gradient colors via the color value;
html
<template>
    <hy-tag label="Tag" type="primary"></hy-tag>
    <hy-tag label="Tag" type="success"></hy-tag>
    <hy-tag label="Tag" type="error"></hy-tag>
    <hy-tag label="Tag" type="warning"></hy-tag>
    <hy-tag label="Tag" type="info"></hy-tag>
    <hy-tag label="Tag" color="#800080"></hy-tag>
    <hy-tag label="Tag" color="#FFF420"></hy-tag>
    <hy-tag label="Tag" color="#A4E82F"></hy-tag>
    <hy-tag label="Tag" color="#E72F8C"></hy-tag>
</template>

Plain Tags ​

  • Set a plain (outlined) background by setting plain
html
<template>
    <hy-tag label="Tag" type="primary" plain></hy-tag>
    <hy-tag label="Tag" type="success" plain></hy-tag>
    <hy-tag label="Tag" type="error" plain></hy-tag>
    <hy-tag label="Tag" type="warning" plain></hy-tag>
    <hy-tag label="Tag" type="info" plain></hy-tag>
    <hy-tag label="Tag" color="#800080" plain></hy-tag>
    <hy-tag label="Tag" color="#FFF420" plain></hy-tag>
    <hy-tag label="Tag" color="#A4E82F" plain></hy-tag>
    <hy-tag label="Tag" color="#E72F8C" plain></hy-tag>
</template>

Plain with Background Color ​

  • Set plainFill to make the background semi-transparent
html
<template>
    <hy-tag label="Tag" type="primary" plain plainFill></hy-tag>
    <hy-tag label="Tag" type="success" plain plainFill></hy-tag>
    <hy-tag label="Tag" type="error" plain plainFill></hy-tag>
    <hy-tag label="Tag" type="warning" plain plainFill></hy-tag>
    <hy-tag label="Tag" type="info" plain plainFill></hy-tag>
    <hy-tag label="Tag" color="#800080" plain plainFill></hy-tag>
    <hy-tag label="Tag" color="#FFF420" plain plainFill></hy-tag>
    <hy-tag label="Tag" color="#A4E82F" plain plainFill></hy-tag>
    <hy-tag label="Tag" color="#E72F8C" plain plainFill></hy-tag>
</template>

Plain with Background Color and No Border ​

html
<template>
  <hy-tag :label="t('label')" type="primary" :border="false" shape="circle"></hy-tag>
  <hy-tag :label="t('label')" type="success" :border="false"></hy-tag>
  <hy-tag
          :label="t('label')"
          type="primary"
          plain
          plain-fill
          :border="false"
          shape="circle"
  ></hy-tag>
  <hy-tag :label="t('label')" type="error" plain plain-fill :border="false"></hy-tag>
</template>

Tag Shapes ​

  • Set the tag shape via shape
    • circle: Semicircle
    • square: Square
    • opposite: Diagonal rounded corners
html
<template>
    <hy-tag label="Circle" shape="circle"></hy-tag>
    <hy-tag label="Square" shape="square"></hy-tag>
    <hy-tag label="Diagonal Rounded" shape="opposite"></hy-tag>
</template>

Closable Tags ​

  • Configure closable to display an icon for removing the tag in the top-right corner
html
<template>
    <up-tag label="Tag" closable :show="show" @close="show = false"></up-tag>
</template>

<script setup>
    import { ref } from 'vue';

    const show = ref(true);
</script>

Tag Size Settings ​

  • The size property provides multiple tag sizes, with medium as the default.
    • large: Large tag
    • medium: Medium tag
    • small: Small tag
    • mini: Mini
html
<template>
    <hy-tag label="Tag" size="large"></hy-tag>
    <hy-tag label="Tag" size="medium"></hy-tag>
    <hy-tag label="Tag" size="small"></hy-tag>
    <hy-tag label="Tag" size="mini"></hy-tag>
</template>

Tag Prefix Icon ​

html
<template>
    <hy-tag label="Address" :icon="IconConfig.MAP"></hy-tag>
    <hy-tag label="Help" :icon="IconConfig.HELP"></hy-tag>
</template>

<script setup>
    import { IconConfig } from '@/hy-app/ui';
</script>

API ​

Tag Props ​

ParameterDescriptionTypeDefault
labelText content of the tagstring-
typeTheme typeerror|warning|success|primary|infoprimary
disabledDisabledbooleanfalse
sizeTag sizemini|small|medium|largemedium
shapeTag shapecircle|square|oppositesquare
bgColorBackground color, defaults to an empty string, i.e., not processedstring-
colorTag font color, defaults to an empty string, i.e., not processedstring-
borderWhether to show the borderbooleantrue
borderColorBorder color of the tagstring-
closeColorColor of the close button iconstring-
valueIndex value returned on click, used to identify which element of the iterated array was clickedstring|number-
plainFillWhether to fill the background color when plainbooleanfalse
plainWhether plain (outlined)booleanfalse
closableWhether closable; when set to true, a close icon appears to the right of the textbooleanfalse
showTag visibilitybooleantrue
iconIcon, see Icon API for detailsHyIconProps-
customStyleDefine external styles to be appliedCSSProperties-
customClassCustom external class nameCSSProperties-

Events ​

Event NameDescriptionCallback Parameters
clickTriggered when the tag is clicked{label: displayed text content, value: text value}
closeTriggered when the tag's close button is clicked while closable is truevalue: text content

CSS Variables ​

VariableDescriptionDefault
--hy-tag-border-widthBorder width2rpx
--hy-tag-padding-minimini padding4rpx 12rpx
--hy-tag-padding-smallsmall padding6rpx 16rpx
--hy-tag-padding-mediummedium padding8rpx 20rpx
--hy-tag-padding-largelarge padding10rpx 24rpx
--hy-tag-close-size-minimini close icon size14px
--hy-tag-close-size-smallsmall close icon size16px
--hy-tag-close-size-mediummedium close icon size20px
--hy-tag-close-size-largelarge close icon size22px
--hy-tag-font-size-minimini font size (line height follows accordingly)Follows --hy-font-size-xs (20rpx)
--hy-tag-font-size-smallsmall font size (line height follows accordingly)Follows --hy-font-size-sm (24rpx)
--hy-tag-font-size-mediummedium font size (line height follows accordingly)Follows --hy-font-size-base (28rpx)
--hy-tag-font-size-largelarge font size (line height follows accordingly)Follows --hy-font-size-md (32rpx)
--hy-tag-close-radiusClose button border radiusFollows --hy-radius-semicircle (100px)
12:33
battery