Skip to content

Tag - Vant 4

Tag ​

Intro ​

Used to mark keywords and summarize the main content.

Install ​

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { Tag } from'vant'; const app = createApp(); app.use(Tag);

Usage ​

Basic Usage ​

html

Plain style ​

html

Round style ​

html

Mark style ​

html

Closeable ​

html
js
import { ref } from'vue'; exportdefault { setup() { const show = ref(true); constclose = () => { show.value = false; }; return { show, close, }; }, };

Custom Size ​

html

Custom Color ​

html

API ​

Props ​

AttributeDescriptionTypeDefault
typeType, can be set to primary``success``danger``warningstringdefault
sizeSize, can be set to large``mediumstring-
colorCustom colorstring-
showWhether to show tagbooleantrue
plainWhether to be plain stylebooleanfalse
roundWhether to be round stylebooleanfalse
markWhether to be mark stylebooleanfalse
text-colorText colorstringwhite
closeableWhether to be closeablebooleanfalse

Slots ​

NameDescription
defaultDefault slot

Events ​

EventDescriptionArguments
clickEmitted when component is clickedevent: MouseEvent
closeEmitted when close icon is clickedevent: MouseEvent

Types ​

The component exports the following type definitions:

ts
importtype { TagSize, TagType, TagProps } from'vant';

Theming ​

CSS Variables ​

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-tag-padding0 var(--van-padding-base)-
--van-tag-text-colorvar(--van-white)-
--van-tag-font-sizevar(--van-font-size-sm)-
--van-tag-radius2px-
--van-tag-line-height16px-
--van-tag-medium-padding2px 6px-
--van-tag-large-paddingvar(--van-padding-base) var(--van-padding-xs)-
--van-tag-large-radiusvar(--van-radius-md)-
--van-tag-large-font-sizevar(--van-font-size-md)-
--van-tag-round-radiusvar(--van-radius-max)-
--van-tag-danger-colorvar(--van-danger-color)-
--van-tag-primary-colorvar(--van-primary-color)-
--van-tag-success-colorvar(--van-success-color)-
--van-tag-warning-colorvar(--van-warning-color)-
--van-tag-default-colorvar(--van-gray-6)-
--van-tag-plain-backgroundvar(--van-background-2)-

Enterprise-level mobile solution based on Vant