file icons
v1.3.2
使用Vscode-Material-Icon-theme在文件树中的文件图标。
访问https://uiwjs.github.io/file-icons/并查看搜索功能,搜索功能具有识别常见图标名称和样式的关键字。例如,如果您搜索“ Swift”,我们将调用所有可能用作箭头的图标。我们还将每个图标的班级名称包括在开发时,以便于复制/粘贴!
他们可以在麻省理工学院自由使用和许可。无论您认为合适,个人或商业都可以使用它们。

npm install @uiw/file-icons --save您可以使用https://uiwjs.github.io/file-icons/轻松找到要使用的图标。一旦复制了所需的图标CSS className,只需将图标和图标的className(例如apple添加到HTML元素中。
假设字体名称定义为ffont ,默认主页是unicode ,将生成:
font-class.html
index.html
symbol.html
react
ffont.json
ffont.css
ffont.eot
ffont.less
ffont.svg
ffont.symbol.svg
ffont.ttf
ffont.woff
ffont.woff2预览演示font-class.html , symbol.html annd index.html 。自动生成的样式ffont.css and ffont.less 。
< svg class = " icon " aria-hidden = " true " >
< use xlink : href = " node_modules/@uiw/file-icons/fonts/ffont.symbol.svg#ffont-javascript " ></ use >
</ svg > < style >
.iconfont {
font-family: "ffont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
</ style >
< span class =" iconfont " >  </ span >支持.less和.css样式参考。
< link rel =" stylesheet " type =" text/css " href =" node_modules/@uiw/file-icons/fonts/ffont.css " >
< i class =" ffont-javascript " > </ i > 图标用作组件。 v1.3.0+支持。
import { Android } from '@uiw/file-icons' ;
// Or
import { Android } from '@uiw/file-icons/Alipay' ;
< Android style = { { fill : 'red' } } />
< Android height = "36" / >要直接将SVG图像作为React组件,需要WebPack加载程序支持。
安装依赖项:
yarn add @svgr/webpack file-loader配置WebPack Loader:
// webpack.config.js
{
test : / .svg$ / ,
use : [
{
loader : require . resolve ( '@svgr/webpack' ) ,
options : {
prettier : false ,
svgo : false ,
svgoConfig : {
plugins : [ { removeViewBox : false } ] ,
} ,
titleProp : true ,
ref : true ,
} ,
} ,
{
loader : require . resolve ( 'file-loader' ) ,
options : {
name : 'static/media/[name].[hash].[ext]' ,
} ,
} ,
] ,
issuer : {
and : [ / .(ts|tsx|js|jsx|md|mdx)$ / ] ,
} ,
} ,然后,您可以将SVG作为反应组件导入:
import { ReactComponent as ComLogo } from '@uiw/file-icons/icon/android.svg' ;
< ComLogo />自定义图标组件
创建Icon组件。
import React from 'react' ;
import svgPaths from '@uiw/file-icons/fonts/ffont.json' ;
const renderSvgPaths = ( type ) => {
const pathStrings = svgPaths [ type ] ;
if ( pathStrings == null ) {
return null
}
return pathStrings . map ( ( d , i ) => < path key = { i } d = { d } fillRule = "evenodd" /> )
}
export default class Icon extends React . PureComponent {
render ( ) {
const { type , color } = this . props ;
if ( type == null || typeof type === "boolean" ) {
return null ;
}
return (
< svg fill = { color } viewBox = { `0 0 24 24` } > { this . renderSvgPaths ( type ) } </ svg >
) ;
}
}使用Icon组件:
const demo = ( ) => {
return (
< Icon type = "android" />
)
} 与往常一样,感谢我们出色的贡献者!
由github-action-contributor制成。
由SVGTOFONT创建,根据MIT许可证获得许可。