Skip to content

Icon Component

A font-based icon set that includes icons for most common scenarios. It's simple to use and works out of the box—no need to write styles for each icon yourself, just a simple configuration will do. Custom icons are supported.

📌 Platform Difference Notes

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯 Basic Usage Examples

Friendly Reminder

The icons use online links from the Alibaba icon library. If the icons fail to load due to poor network conditions when accessing the repository, this is normal. You can download the icons locally and import them yourself. If you need to download the icons locally, please contact the author: Huayue

html
<!-- Global import -->
<hy-icon :name="IconConfig.Loading"></hy-icon>

Modifying Icon Styles

  • Use the color parameter to change the icon's color
  • Use the size parameter to change the icon's size, in px
html
<hy-icon name="photo" color="#2979ff" size="28"></hy-icon>

Image Icons (with Rounded Corners)

html
<view class="hy-flex">
    <hy-icon
        name="https://q9.itc.cn/q_70/images03/20250211/6ee1b8e0f4704083ba715986c8c3795f.jpeg"
        size="80"
        round="5px"
    />
</view>

Icon Text Position

html
<view class="hy-flex">
    <hy-icon :name="IconConfig.LOCK" label="Horizontal" label-pos="right" />
    <hy-icon :name="IconConfig.LOCK" label="Vertical" label-pos="bottom" />
</view>

Icon Rotation

html
<view class="hy-flex">
    <hy-icon :name="IconConfig.LOCK" is-rotate />
</view>

Custom Icons

  • Download directly from the Alibaba vector icon library
    • name is the icon name
    • customPrefix is the FontClass/Symbol prefix from your project settings
html
<hy-icon label="uview-plus" size="40" name="search" customPrefix="custom-icon"></hy-icon>

Note

The default class name after downloading is .iconfont; you need to manually replace .iconfont with .custom-icon

scss
@font-face {
  font-family: "custom-icon";
  src: url('iconfont.woff2?t=1764230155023') format('woff2'),
  url('iconfont.woff?t=1764230155023') format('woff'),
  url('iconfont.ttf?t=1764230155023') format('truetype');
}

.iconfont { 
.custom-icon { 
  font-family: "custom-icon";
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

API

Icon Props

ParameterDescriptionTypeDefault Value
nameIcon name, see the example icon setstring | IconConfig-
sizeIcon font size, default unit for numeric values is pxstring | number16px
colorIcon colorstring-
boldWhether to display in boldbooleanfalse
indexA value used to distinguish multiple icons; passed out through the click event when the icon is clickedstring | number-
hoverClassStyle class applied when the icon is pressed; works the same as the hover-class parameter of uni's view component. See: hover-classstring-
customPrefixMust be set when using a custom font icon library. See: Extending Custom Icon Librariesstringhy-icon
labelLabel text to the right of/below the iconstring-
labelPosPosition of the label relative to the iconstringright
labelSizeLabel font size, default unit for numeric values is pxstring | number-
labelColorLabel font colorstring-
spaceDistance between the label and the icon, default unit for numeric values is pxstring | number3px
imgModeImage cropping/scaling mode, a native property of the image component. See: imagestring-
widthImage width when name is an image path, default unit for numeric values is pxstring | number-
heightImage height when name is an image path, default unit for numeric values is pxstring | number-
topDistance from the icon to the top; in certain scenarios, if the icon is not vertically centered, you can adjust this parameter. Default unit for numeric values is pxstring | string | number0
stopWhether to stop event propagationboooleanfalse
isRotateWhether to auto-rotate (used for loading)boooleanfalse
roundIcon border radius, default unit for numeric values is pxstring | number-
customStyleCustom external styles to be appliedCSSProperties-
customClassCustom external class namestring-

Events

Event NameDescriptionCallback Parameters
clickTriggered when the icon is clickedindex: the index value passed via props

Icon Set

加载动画LOADING
关闭CLOSE
空星STAR
实星STAR_FILL
微笑SMILE
微笑-实心SMILE_FILL
难过-实心CRY_FILL
打勾,勾选CHECK_MASK
编辑EDIT
商城SHOP
实心锁LOCK_FILL
打开实心锁LOCK_OPEN_FILL
空心锁LOCK
地点MAP
地点-实心MAP_FILL
购物车SHOPPING_CART
购物车-实心SHOPPING_CART_FILL
添加购物车SHOPPING_CART_ADD
购物袋SHOPPING_BAG
刷新REFRESH
任务TASK
标签TAG
LEFT
RIGHT
UP
DOWN
向上-实心ARROW_UP_FILL
向下-实心ARROW_DOWN_FILL
向左-实心ARROW_LEFT_FILL
向右-实心ARROW_RIGHT_FILL
向左双箭头ARROW_DOUBLE_LEFT
向右双箭头ARROW_DOUBLE_RIGHT
箭头向左ARROW_LEFTWARD
箭头向右ARROW_RIGHTWARD
箭头向上ARROW_UPWARD
箭头向下ARROW_DOWNWARD
历史HISTORY
时间TIME
网络NETWORK
列表LIST_DOT
菜单MENU
搜索SEARCH
PLUS
MINUS
提醒REMIND
提醒-实体REMIND_FILL
警告WARNING
警告-实心WARNING_FILL
删除DELETE
删除-实心DELETE_FILL
筛选SCREEN
分类CLASS
应用CLASS_FILL
首页HOME
首页-实心HOME_FILL
我的MINE
我的-实心MINE_FILL
设置SETTING
设置-实体SETTING_FILL
关闭圆圈CLOSE_CIRCLE
关闭圆圈-实心CLOSE_CIRCLE_FILL
注意NOTICE
注意-圆形NOTICE_CIRCLE
注意-实心NOTICE_FILL
成功SUCCESS
成功-实心SUCCESS_FILL
问号QUERY
帮助HELP
帮助-实心HELP_FILL
上传UPLOAD
转换SWITCH
下载DOWNLOAD
保护SECURITY
扫码SCAN
保存SAVE
图片PHOTO
图片-实体PHOTO_FILL
pdfPDF
导航NAVIGATION
打印PRINT
layersLAYERS
链接LINK
导出EXPORT
省略号ELLIPSIS
客服CUSTOMER_SERVICE
信息COMMENT
消息MESSAGE
消息-实心MESSAGE_FILL
通知-实心NOTIFICATION_FILL
附件ATTACHMENT
相机CAMERA
眼睛EYE
眼睛-关闭EYE_CLOSE
隐藏HIDE
日历CALENDAR
复制COPY
订单ORDER
分享SHARE
分享-实心SHARE_FILL
发送SEND
打出电话TELEPHONE_OUT
电话TELEPHONE
电话-实心TELEPHONE_FILL
话筒MIC
数据占比PIE_CHART
数据视图BAR_CHART
03:29