Skip to content

Icon

Font-based icon set.

Component Type

Basic Usage

Set which icon to use through the name property.

html
<wd-icon name="del" />

Component Style

Icon Color

Set the color property.

html
<wd-icon name="del" color="#0083ff" />

Icon Size

Set the size property.

html
<wd-icon name="del" size="20px" />

Special Style

Custom Icons

If you need to use more icons on top of the existing Icon, you can import the font files and CSS files corresponding to third-party iconfont, and then use them directly in the Icon component.

/* Path src/iconfont/index.css */

@font-face {
  font-family: "fish";
  src: url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.woff2?t=1721314121733') format('woff2'),
       url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.woff?t=1721314121733') format('woff'),
       url('//at.alicdn.com/t/c/font_4626013_vwpx4thmin.ttf?t=1721314121733') format('truetype');
}

.fish {
  font-family: "fish" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.fish-kehuishouwu:before {
  content: "\e627";
}
html
<!-- app.vue -->
<style>
@import '@/iconfont/index.css';
</style>
html
<!-- Specify class name as fish through class-prefix -->
<wd-icon class-prefix="fish" name="kehuishouwu" />

CSS Class Icons (UnoCSS)

If your project uses UnoCSS or other CSS engines, you can set css-icon to true. In this case, the passed name will be directly used as a CSS class name without any prefix concatenation.

html
<wd-icon css-icon name="i-ep-apple" />
<wd-icon css-icon name="i-carbon-sun" />

Attributes

ParameterDescriptionTypeDefault Value
nameIcon name or image linkstring-
colorIcon colorstringinherit
sizeIcon font sizestring | numberinherit
class-prefixClass name prefix, used for custom iconsstringwd-icon
css-iconWhether it is a CSS class icon (such as UnoCSS icon). When true, name is directly used as CSS classbooleanfalse
custom-styleRoot node stylestring-
custom-classRoot node stylestring-

Events

Event NameDescriptionParameters
clickTriggered when clicking the iconevent

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-icon-font-size$typography-body-size-main图标字号

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.