Giter VIP home page Giter VIP logo

xicons's Introduction

xicons License: MIT

English · 中文

Include vicons(vue3), ricons(react), sicons(svg) & v2icons(vue2).

SVG Vue/React components integrated from fluentui-system-icons, ionicons, ant-design-icons, material-design-icons, Font-Awesome, tabler-icons and carbon.

Util icon component for customizing color & size is also provided.

Icons Preview & Search

https://www.xicons.org

Installation

Icons Installation

# Install packages on your demand
# For react
npm i -D @ricons/fluent
npm i -D @ricons/ionicons4
npm i -D @ricons/ionicons5
npm i -D @ricons/antd
npm i -D @ricons/material
npm i -D @ricons/fa # font awesome
npm i -D @ricons/tabler
npm i -D @ricons/carbon
# For vue3
npm i -D @vicons/fluent
npm i -D @vicons/ionicons4
npm i -D @vicons/ionicons5
npm i -D @vicons/antd
npm i -D @vicons/material
npm i -D @vicons/fa # font awesome
npm i -D @vicons/tabler
npm i -D @vicons/carbon
# For vue2
npm i -D @v2icons/fluent
npm i -D @v2icons/ionicons4
npm i -D @v2icons/ionicons5
npm i -D @v2icons/antd
npm i -D @v2icons/material
npm i -D @v2icons/fa # font awesome
npm i -D @v2icons/tabler
npm i -D @v2icons/carbon
# For SVG file
npm i -D @sicons/fluent
npm i -D @sicons/ionicons4
npm i -D @sicons/ionicons5
npm i -D @sicons/antd
npm i -D @sicons/material
npm i -D @sicons/fa # font awesome
npm i -D @sicons/tabler
npm i -D @sicons/carbon

Icon Utils Installation

Icon utils provide a icon wrapper component for customizing color & size of the inner SVG icon.

npm i -D @ricons/utils  # react
npm i -D @vicons/utils  # vue3
npm i -D @v2icons/utils # vue2

Usage

For Vue3

vue3 demo

<script>
  import { Money16Regular } from '@vicons/fluent'
  // or
  import Money16Regular from '@vicons/fluent/Money16Regular'

  // You can directly use the SVG component
  // or wrap it in an Icon component from @vicons/utils

  import { Icon } from '@vicons/utils'

  export default {
    components: {
      Icon,
      Money16Regular
    }
  }
</script>

<template>
  <Icon>
    <Money16Regular />
  </Icon>
</template>

Q & A

  • (Vue3) How to create a function that accepts an icon component as input in TypeScript?
import type { Component } from 'vue'

function f(iconComponent: Component) {
  // ...
}

For React

react demo

import { Money16Regular } from '@ricons/fluent'
// or
import Money16Regular from '@ricons/fluent/Money16Regular'

// You can directly use the SVG component
// or wrap it in an Icon component from @ricons/utils
import { Icon } from '@ricons/utils'

function App() {
  return (
    <Icon>
      <Money16Regular />
    </Icon>
  )
}

For Vue2

vue2 demo

<script>
  import { Money16Regular } from '@v2icons/fluent'
  // or
  import Money16Regular from '@v2icons/fluent/Money16Regular'

  // You can directly use the SVG component
  // or wrap it in an Icon component from @v2icons/utils

  import { Icon } from '@v2icons/utils'

  export default {
    components: {
      Icon,
      Money16Regular
    }
  }
</script>

<template>
  <Icon>
    <Money16Regular />
  </Icon>
</template>

For SVG

<img src="@sicons/fluent/Money16Regular.svg" />

Utils API

Icon API

An icon component (in @vicons/utils, @ricons/utils, @v2icons/utils) is provided for customizing color & size of the inner SVG icon.

prop type default description
size string | number - Size of the icon.
color string - Color of the icon.
tag string span Tag to be rendered as.

For example:

import { Icon } from '@ricons/utils' // react
import { Icon } from '@vicons/utils' // vue3
import { Icon } from '@v2icons/utils' // vue2

// render it
;<Icon color="green" size="48">
  <SomeIcon />
</Icon>

IconConfigProvider API

IconConfigProvider will affect all the descendant Icons' default prop value.

prop type default description
size string | number - Size of the icon.
color string - Color of the icon.
tag string span Tag to be rendered as.

For example:

import { IconConfigProvider, Icon } from '@ricons/utils'  // react
import { IconConfigProvider, Icon } from '@vicons/utils'  // vue3
import { IconConfigProvider, Icon } from '@v2icons/utils' // vue2

// render it
;<IconConfigProvider color="green" size="48">
  <App>
    <Icon>
      <SomeIcon />
    </Icon>
  <App/>
</IconConfigProvider>

Common Issues

too many open files

This is because the count of opened files exceeds the limit of operation system.

Use ulimit -n to check the limit.

You can only increase the limit or import icons by path:

import Money16Regular from '@ricons/fluent/Money16Regular'

Icon Utils Packages

package version description
@ricons/utils npm version Util icon components for react.
@vicons/utils npm version Util icon components for vue3.
@v2icons/utils npm version Util icon components for vue2.

Icon Packages

Vue3

package version
@vicons/fluent npm version
@vicons/ionicons4 npm version
@vicons/ionicons5 npm version
@vicons/antd npm version
@vicons/material npm version
@vicons/fa npm version
@vicons/tabler npm version
@vicons/carbon npm version

React

package version
@ricons/fluent npm version
@ricons/ionicons4 npm version
@ricons/ionicons5 npm version
@ricons/antd npm version
@ricons/material npm version
@ricons/fa npm version
@ricons/tabler npm version
@ricons/carbon npm version

Vue2

package version
@v2icons/fluent npm version
@v2icons/ionicons4 npm version
@v2icons/ionicons5 npm version
@v2icons/antd npm version
@v2icons/material npm version
@v2icons/fa npm version
@v2icons/tabler npm version
@v2icons/carbon npm version

SVG

package version
@sicons/fluent npm version
@sicons/ionicons4 npm version
@sicons/ionicons5 npm version
@sicons/antd npm version
@sicons/material npm version
@sicons/fa npm version
@sicons/tabler npm version
@sicons/carbon npm version

Credit

Icon Set License
ant-design-icons MIT
fluentui-system-icons MIT
Font-Awesome CC BY 4.0 License
ionicons MIT
material-design-icons Apache 2
tabler-icons MIT
carbon Apache 2

xicons's People

Contributors

07akioni avatar dependabot-preview[bot] avatar dependabot[bot] avatar orbisk avatar pluwen avatar shooklyngs 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  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  avatar  avatar

xicons's Issues

如何动态引入图标?

例如使用iconicons5 antd等的图标,由用户自己选择

服务端返回对应字符串, 例如 “Add”

如何根据服务端返回的字段进行动态加载图标?

Use Iconify as icon source

Awesome work on this! Interesting to see the usage of different icons types!

This project seems to included 7 iconsets, which I think it's already great. I also do understand adapting more icon libraries would require much more effort. So instead of requesting for new icon collections support, how about considering use Iconify's collection as the data source?

https://github.com/iconify/collections-json

@cyberalien has working really hard on collecting over 90+ icon collections into a uniformed json collection.

On top of Iconify, I also built a few tools you might be interested

That said, I would be love to see this project adapting to reuse Iconify's collection to support much more icon collections with less effort. While providing a unified ecosystem and developer experience.

Thanks!

Why can't icons be parsed dynamically?

Example
in vue3 render function
I want to render different icons in real time through strings

const test: object[] = [
    {
        key: 'xcionsComponentName'
    },
    {
        key: 'xcionsComponentName2'
    }
]

I want to use key or other variable names to control the display xicons svg

Hosting xicons.org locally?

The site xicons.org is not always accessible from my ISP, may I get access to the site repository and host it on my machine?

Fluent icons missing

Hello,
some fluent icons are missing, for example "NumberSymbolSquare24Regular", there's a planned update?

Thank you for the great work!!

How to introduce custom svg icon to project?

There are so many icon vendors, that's great. But sometimes we need to customize our own icon by introducing svg file from UI designer, it's seems there's not docs about it.

通过 import {xxx} from '@xicons/material' 引入导致 VSCode 中语法提示加载缓慢

代码如下:

<!-- App.vue -->
<script setup lang="ts">
import { NButton, NIcon } from 'naive-ui'
// 语法提示加载缓慢
import { ErrorFilled } from '@vicons/material'
// 无问题
// import ErrorFilled from '@vicons/material/ErrorFilled'
</script>

<template>
  <NIcon :component="ErrorFilled" />
  <NButton>确定</NButton>
</template>

在 NButton 上键入属性(如 style,type 等)语法提示会加载较长时间,是否有办法优化?

环境: Windows 10 + VSCode 1.68.0 + Volar 0.37.6

是否能够提供SVG路径导出功能?

需求是在ECharts中使用图标库,但是ECharts的图标引入方式比较奇怪:Documentation - Apache ECharts

大致有如下三种:

  • image://http(s)://...
  • image://data:image/...
  • path://...

@sicons提供的svg文件无法很好地配合第一种情况使用,因为路径拼接之后,打包工具不认。

所以希望能够提供一个导出svg路径为string的功能,以配合第三种情况使用。

Having problem in antd

Im using Vue 3, their is something wrong with the antd icons. It has error.

import ExportOutlined from '@vicons/antd/ExportOutlined';

export default defineComponent({
    components: {
        ExportOutlined,
    },
})

This is the error
image

The `tsc` memory usage problem

I have an existing vite project with @ricons/material and @ricons/antd as devDependencies, and when I ran tsc --diagnostics command , here's the result:

Files:             12372
Lines:            218414
Identifiers:      345716
Symbols:          198770
Types:             16247
Instantiations:    79425
Memory used:    2166158K
I/O read:          0.55s
I/O write:         0.00s
Parse time:        3.74s
Bind time:         1.08s
Check time:        1.10s
Emit time:         0.00s
Total time:        5.91s

Then I added the @ricons/fluent to devDependencies, imported an icon from the library, and then re-ran the command again, here's the result:

Files:             22443
Lines:            268767
Identifiers:      486698
Symbols:          249123
Types:             16248
Instantiations:    79425
Memory used:    3877564K
I/O read:          1.91s
I/O write:         0.00s
Parse time:       10.67s
Bind time:         3.06s
Check time:        4.51s
Emit time:         0.00s
Total time:       18.25s

We can see that with the new icon package added to the devDependencies, the tsc program had to use much more memory than before. How can we resolve it?

material 图标不能成功引入

你好,我是 Windows10 系统,没办法使用 ulimit 命令,我在引入 material 图标的时候一直不成功
image
之后换成引用 fa 图标就可以了,我看到 material 文件夹下有 21118 个项目,是否可以考虑优化一下文件数量以防止这个问题的出现,或者说这个问题不是文件数量太大导致的?

Invalid DOM properties in react icon components

Console output shows warnings about invalid properties:

  • 'Warning: Invalid DOM property stroke-linecap. Did you mean strokeLinecap?'
  • 'Warning: Invalid DOM property stroke-linejoin. Did you mean strokeLinejoin?'
  • 'Warning: Invalid DOM property stroke-width. Did you mean strokeWidth?'
  • ...etc.

So that these warnings are not shown, I suppose in the script for generating react components we need to convert all attributes into camelCase

Enable Treeshaking

Hi all,

thanks for maintaining this library! It would be great is we can enable tree shaking for the imports.

What is missing and how would an implementation look like?

Thanks

使用 @vicons/ionicons5 控制台报错

报错信息如下:

No required version specified and unable to automatically determine one. Unable to find required version for "vue" in description file (/home/web/node_modules/.pnpm/@[email protected]/node_modules/@vicons/ionicons5/package.json). It need to be in dependencies, devDependencies or peerDependencies.

通过Nuxt3使用时出错

"nuxt": "^3.5.1"
"@css-render/vue3-ssr": "^0.15.12",
"@vicons/ionicons5": "^0.12.0",
"naive-ui": "^2.34.4",

在SSR模式下,通过NaiveUI的<n-icon>标签引入时报错,页面提示Body is unusable,控制台出现警告

[Vue warn]: Component LayoutLoader is missing template or render function.

Phosphor icons

Heyho,

What would it take to integrate Phosphor icons? Happy to help! But just by skimming over the code, I'm not 100% sure I get how it works.

Cheers,
Luka

找不到模块“@vicons/ionicons5”或其相应的类型声明 Module "@vicons/ionicons5" or its corresponding type declaration could not be found

问题:

在一个项目里,唯独@vicons/ionicons5找不到模块,但是运行时正常,能够正常渲染图标

import { Video48Regular, VideoOff48Regular, Video48Filled } from '@vicons/fluent';
import { VideocamOutline } from '@vicons/ionicons5' // 找不到模块“@vicons/ionicons5”或其相应的类型声明。
import { MdVideocam } from '@vicons/ionicons4'
import { VideoCameraOutlined } from '@vicons/antd'
import { PhotoVideo } from '@vicons/fa'
import { FeaturedVideoOutlined } from '@vicons/material'
import { VideoOff } from '@vicons/tabler'
import { VideoAdd } from '@vicons/carbon'

Snipaste_2023-09-09_13-51-25

Snipaste_2023-09-09_13-40-53

feature: add support for a resolver for unplugin-auto-import

Given the current nature of how many icons exist within each sub-package, it'd be nice to have support to auto-import icons using antfu/unplugin-auto-import.

Normally it'd be pretty easy to add a custom resolver, however due to the icons not having naming prefixes, my guess is the best bet is generating a resolver for each package, that includes the list of importable icons.

The benefit in doing so, if folks use unplugin-auto-import, is that they no longer need to import any icons, and only the referenced icons are actually bundled.

Thoughts?

可否新增设置自行添加图标的功能?

可否新增自行添加图表的功能呢?
让UI设计完的svg批量导入到xicons中本地引用图标。
并且可以使这些图标能享受到xicon的API,方便对其进行管理。

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.