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許可證獲得許可。