Coder Social home page Coder Social logo

taro-icons's Introduction

taro-icons

基于 Taro 的小程序图标库

example

特性

  • 按需加载,根据自身需要选择加载不同的图标库,减少包大小
  • 大约 6700 个 icon 可供选择

支持的图标库:

安装

npm install taro-icons --save

使用

app.js 中导入你需要的图标库scss 文件,如 MaterialIcons:

// app.js
// 请根据需要选择导入的 scss,这里全部导入
import 'taro-icons/scss/MaterialCommunityIcons.scss' // 495KB
import 'taro-icons/scss/MaterialIcons.scss' // 112KB
import 'taro-icons/scss/Ionicons.scss' // 134KB
import 'taro-icons/scss/FontAwesome.scss' // 322KB

然后在需要用到图标的地方引入对应d的component使用:

import {
  MaterialIcons,
  MaterialCommunityIcons,
  Ionicons,
  FontAwesome,
} from 'taro-icons';
...

<MaterialIcons name='settings' size={24} color='#000000' />
<MaterialCommunityIcons name='account' size={32} color='#000000' />
<Ionicons name='ios-woman' size={32} color='pink' />
<FontAwesome family='brands' name='weixin' size={32} />

其中name必填,可以在对应的网站上找到
具体用法请参考 example

Icon props

属性 说明 类型 默认值
name 需要显示的图标名称,可以在对应图标库网站找到 String
size 图标大小(px) Number 24
color 图标颜色 String #000000
family FontAwesome 特有属性(solid、regular、brands) String solid

⚠️注意事项

微信开发者工具中,选择 设置 -> 项目设置 -> 调试基础库,设置版本2.2.3及以上,图标才能正常显示

taro-icons's People

Contributors

dependabot[bot] avatar jeepeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

marquis-h

taro-icons's Issues

尝试了一下h5,没有跑起来

尝试了一下h5,没有跑起来报 Super expression must either be null or a function, not undefined错误。

尝试了百度、支付宝、头条三端都可以用的

另外一种集成 micon的方案

yarn add material-design-icons
// index.tsx
import "material-design-icons/iconfont/material-icons.css";

// util/icon.tsx
import { Text } from "@tarojs/components";

const MIcon = ({ name, color = PRIMARY_COLOR, size = 24 }: any) => <Text className='material-icons' style={{
  color: color,
  fontSize: size,
  width: size
}}
>{(name || '').replace(/-/g, '_')}</Text>

export { MIcon };

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.