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

Icon

Intro

The font-based icon set that can be used via the Icon component or referenced in other components via the icon attribute.

Install

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

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

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

Usage

Basic Usage

Use name prop to set icon name or icon URL.

<van-icon name="chat-o" />

Using URL

You can directly passing an image URL to the name props.

<van-icon name="https://fastly.jsdelivr.net/npm/@vant/assets/icon-demo.png" />

Show Badge

Use dot prop, a small red dot will be displayed in the upper right corner of the icon.

Use badge prop, the badge will be displayed in the upper right corner of the icon.

<van-icon name="chat-o" dot />
<van-icon name="chat-o" badge="9" />
<van-icon name="chat-o" badge="99+" />

Icon Color

Use color prop to set icon color.

<van-icon name="cart-o" color="#1989fa" />
<van-icon name="fire-o" color="#ee0a24" />

Icon Size

Use size prop to set icon size.

<!-- Using px unit by default -->
<van-icon name="chat-o" size="40" />
<!-- Using rem unit -->
<van-icon name="chat-o" size="3rem" />

Add custom iconfont

@font-face {
  font-family: 'my-icon';
  src: url('./my-icon.ttf') format('truetype');
}

.my-icon {
  font-family: 'my-icon';
}

.my-icon-extra::before {
  content: '\\e626';
}
<van-icon class-prefix="my-icon" name="extra" />

API

Props

AttributeDescriptionTypeDefault
nameIcon name or URLstring''
dotWhether to show red dotbooleanfalse
badgeContent of the badgenumber | string''
badge-props v3.2.8Props of Badge, see Badge - propsBadgeProps-
colorIcon colorstringinherit
sizeIcon sizenumber | stringinherit
class-prefixClassName prefixstringvan-icon
tagHTML Tag of root elementstringi

Events

EventDescriptionArguments
clickEmitted when icon is clickedevent: MouseEvent

Types

The component exports the following type definitions:

import type { IconProps } from 'vant';
`,14),l=[c],h={__name:"README",setup(o,{expose:s}){return s({frontmatter:{}}),(d,r)=>(a(),t("div",e,l))}};export{h as default};