展示图标基本使用方法。
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
size | 指定图标大小 可选值 xxs, xs, small, medium, large, xl, xxl, xxxl, inherit | Enum/Number | 'medium' |
type | 指定显示哪种图标 | String | - |
通过自定义 iconfont源来使用使用svg格式的图片,默认有缓存处理
import { Icon } from '@alifd/next'; const CustomIcon = Icon.createFromIconfontCN({ scriptUrl: '//at.alicdn.com/t/font_1464085_egnk4s8yv2f.js', }); // 同 Icon 基础元素一样,有相同的 size 设定 ReactDOM.render( <div> <CustomIcon type="icon-store" size="small"/> <CustomIcon type="icon-gift"/> <CustomIcon type="icon-pic" size="large"/> </div> , mountNode);
点击图标复制代码。
ICON的尺寸包括:xxs,xs,small,medium,large,xl,xxl,xxxl。
图标字体本质上还是文字,可以使用 style 和 className 设置图标的大小和颜色。