Skip to content

Icon Component ​

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

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage ​

Friendly Reminder

The icons use online links from the Alibaba icon library. If 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: Hy Author

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

Modify Icon Styles ​

  • Modify the icon color via the color parameter
  • Modify the icon size via the size parameter, in px
html
<hy-icon name="photo" color="#2979ff" size="28"></hy-icon>

Image Icon (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 Icon ​

  • Download directly from the Alibaba vector icon library,
    • name is the icon name,
    • customPrefix is the FontClass/Symbol prefix in 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
nameIcon name, see the example icon setstring | IconConfig-
sizeIcon font size, defaults to px for numeric valuesstring | number16px
colorIcon colorstring-
boldWhether to display in boldbooleanfalse
indexA value used to distinguish multiple icons, passed out via the click event when the icon is clickedstring | number-
hoverClassThe style class applied when the icon is pressed, same usage as the hover-class parameter of uni's view component. See: hover-classstring-
customPrefixWhen using a custom font icon library, this value must be specified. See: Extending Custom Icon Librarystringhy-icon
labelLabel text displayed to the right/below the iconstring-
labelPosPosition of the label relative to the iconstringright
labelSizeLabel font size, defaults to px for numeric valuesstring | number-
labelColorLabel font colorstring-
spaceDistance between the label and the icon, defaults to px for numeric valuesstring | number3px
imgModeImage cropping/scaling mode, a native attribute of the image component. See: imagestring-
widthImage width when name is an image path, defaults to px for numeric valuesstring | number-
heightImage height when name is an image path, defaults to px for numeric valuesstring | number-
topDistance from the icon to the top. In some scenarios, if the icon is not vertically centered, you can adjust this parameter. Defaults to px for numeric valuesstring | string | number0
stopWhether to stop event propagationboooleanfalse
isRotateWhether to rotate automatically (used for loading)boooleanfalse
roundIcon border radius, defaults to px for numeric valuesstring | 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

CSS Variables ​

VariableDescriptionDefault
--hy-icon-label-max-widthMaximum width of the label text150rpx
--hy-icon-label-colorLabel text colorFollows --hy-text-color--grey
--hy-icon-label-font-sizeLabel font sizeFollows --hy-font-size-sm (24rpx)

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
12:33
battery