/*! For license information please see 1817.d3fa9e0c.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["1817"],{97261:function(s,n,a){"use strict";a.r(n);var t=a("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
The font-based icon set that can be used via the Icon component or referenced in other components via the icon
attribute.
Register component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Icon } from 'vant';\n\nconst app = createApp();\napp.use(Icon);\n
\nUse name
prop to set icon name or icon URL.
<van-icon name="chat-o" />\n
\nYou can directly passing an image URL to the name
props.
<van-icon name="https://fastly.jsdelivr.net/npm/@vant/assets/icon-demo.png" />\n
\nUse 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 />\n<van-icon name="chat-o" badge="9" />\n<van-icon name="chat-o" badge="99+" />\n
\nUse color
prop to set icon color.
<van-icon name="cart-o" color="#1989fa" />\n<van-icon name="fire-o" color="#ee0a24" />\n
\nUse size
prop to set icon size.
<!-- Using px unit by default -->\n<van-icon name="chat-o" size="40" />\n<!-- Using rem unit -->\n<van-icon name="chat-o" size="3rem" />\n
\n@font-face {\n font-family: 'my-icon';\n src: url('./my-icon.ttf') format('truetype');\n}\n\n.my-icon {\n font-family: 'my-icon';\n}\n\n.my-icon-extra::before {\n content: '\\e626';\n}\n
\n<van-icon class-prefix="my-icon" name="extra" />\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
name | \nIcon name or URL | \nstring | \n\'\' | \n
dot | \nWhether to show red dot | \nboolean | \nfalse | \n
badge | \nContent of the badge | \nnumber | string | \n\'\' | \n
badge-props | \nProps of Badge, see Badge - props | \nBadgeProps | \n- | \n
color | \nIcon color | \nstring | \ninherit | \n
size | \nIcon size | \nnumber | string | \ninherit | \n
class-prefix | \nClassName prefix | \nstring | \nvan-icon | \n
tag | \nHTML Tag of root element | \nstring | \ni | \n
Event | \nDescription | \nArguments | \n
---|---|---|
click | \nEmitted when icon is clicked | \nevent: MouseEvent | \n
The component exports the following type definitions:
\nimport type { IconProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-icon-font-family | \n\'van-icon\' | \n- | \n