import{o as a,a as t,y as n}from"./vue-libs.b44bc779.js";const l={class:"van-doc-markdown-body"},e=n(`

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.

import { createApp } from 'vue';
import { Tag } from 'vant';

const app = createApp();
app.use(Tag);

Usage

Basic Usage

<van-tag type="primary">Tag</van-tag>
<van-tag type="success">Tag</van-tag>
<van-tag type="danger">Tag</van-tag>
<van-tag type="warning">Tag</van-tag>

Plain style

<van-tag plain type="primary">Tag</van-tag>

Round style

<van-tag round type="primary">Tag</van-tag>

Mark style

<van-tag mark type="primary">Tag</van-tag>

Closeable

<van-tag :show="show" closeable size="medium" type="primary" @close="close">
  Tag
</van-tag>
import { ref } from 'vue';

export default {
  setup() {
    const show = ref(true);
    const close = () => {
      show.value = false;
    };

    return {
      show,
      close,
    };
  },
};

Custom Size

<van-tag type="primary">Tag</van-tag>
<van-tag type="primary" size="medium">Tag</van-tag>
<van-tag type="primary" size="large">Tag</van-tag>

Custom Color

<van-tag color="#7232dd">Tag</van-tag>
<van-tag color="#ffe1e1" text-color="#ad0000">Tag</van-tag>
<van-tag color="#7232dd" plain>Tag</van-tag>

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:

import type { 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-border-radius2px-
--van-tag-line-height16px-
--van-tag-medium-padding2px 6px-
--van-tag-large-paddingvar(--van-padding-base) var(--van-padding-xs)-
--van-tag-large-border-radiusvar(--van-border-radius-md)-
--van-tag-large-font-sizevar(--van-font-size-md)-
--van-tag-round-border-radiusvar(--van-border-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-background-colorvar(--van-background-color-light)-
`,18),d=[e],i={__name:"README",setup(p,{expose:s}){return s({frontmatter:{}}),(c,o)=>(a(),t("div",l,d))}};export{i as default};