react-icons vs react-feather vs react-svg vs react-fontawesome
React 圖示庫
react-iconsreact-featherreact-svgreact-fontawesome類似套件:

React 圖示庫

這些圖示庫提供了在 React 應用中使用的各種圖示,旨在簡化圖示的使用和管理。這些庫各有特點,適合不同的需求和使用場景,讓開發者能夠輕鬆地將圖示整合到他們的應用中。

npm下載趨勢

3 年

GitHub Stars 排名

統計詳情

套件
下載數
Stars
大小
Issues
發布時間
許可
react-icons11,796,36412,70288.3 MB2455 個月前MIT
react-feather610,2641,9491 MB39-MIT
react-svg523,08288383.6 kB53 天前MIT
react-fontawesome52,008665-97 年前MIT

功能比較: react-icons vs react-feather vs react-svg vs react-fontawesome

圖示風格

  • react-icons:

    react-icons 整合了多個圖示庫,提供了各種風格的圖示,讓開發者可以根據需求選擇不同的圖示風格。

  • react-feather:

    react-feather 提供了一組簡約且現代的圖示,設計風格輕巧,適合需要簡單清晰視覺效果的應用。

  • react-svg:

    react-svg 允許開發者使用自定義的 SVG 圖示,並能夠直接操作其屬性,適合需要高度自定義的應用。

  • react-fontawesome:

    react-fontawesome 提供了豐富多樣的圖示,涵蓋了各種主題和風格,適合需要多樣化圖示的應用。

性能

  • react-icons:

    react-icons 的性能取決於所使用的具體圖示庫,通常提供良好的性能,但需要注意圖示的加載方式。

  • react-feather:

    react-feather 的圖示是輕量級的 SVG,能夠快速加載,對性能影響較小,適合對性能有高要求的應用。

  • react-svg:

    react-svg 允許直接操作 SVG,這樣可以優化性能,特別是在需要動態改變圖示屬性的情況下。

  • react-fontawesome:

    react-fontawesome 由於圖示數量龐大,可能會影響加載時間,但可以通過按需加載來優化性能。

可擴展性

  • react-icons:

    react-icons 由於整合了多個庫,具有良好的擴展性,可以根據需要選擇不同的圖示庫。

  • react-feather:

    react-feather 的設計簡單,易於擴展,可以輕鬆添加自定義圖示。

  • react-svg:

    react-svg 允許開發者完全控制 SVG 的屬性,提供了高度的可擴展性,適合需要自定義的應用。

  • react-fontawesome:

    react-fontawesome 提供了豐富的 API 和自定義選項,適合需要擴展功能的應用。

使用方便性

  • react-icons:

    react-icons 的使用方式統一,簡單易懂,適合需要快速集成的項目。

  • react-feather:

    react-feather 的 API 簡單明瞭,易於上手,適合新手和快速開發。

  • react-svg:

    react-svg 需要對 SVG 有一定的了解,使用上可能稍微複雜,但提供了靈活性。

  • react-fontawesome:

    react-fontawesome 提供了詳細的文檔和範例,使用方便,適合各種開發者。

社群支持

  • react-icons:

    react-icons 由於整合了多個庫,社群支持廣泛,能夠找到多種資源和範例。

  • react-feather:

    react-feather 擁有活躍的社群,提供了良好的支持和更新。

  • react-svg:

    react-svg 的社群相對較小,但仍然提供了基本的支持和文檔。

  • react-fontawesome:

    react-fontawesome 是一個非常流行的庫,擁有大量的使用者和豐富的資源。

如何選擇: react-icons vs react-feather vs react-svg vs react-fontawesome

  • react-icons:

    如果你想要一個包含多種圖示庫的綜合解決方案,選擇 react-icons。它整合了多個流行的圖示庫,讓你可以輕鬆切換和使用不同風格的圖示。

  • react-feather:

    如果你需要輕量級的圖示,並且喜歡簡潔的設計,選擇 react-feather。它提供了一組簡單的 SVG 圖示,適合需要快速加載和簡約風格的項目。

  • react-svg:

    如果你需要高度可定制的 SVG 圖示,並且希望能夠直接操作 SVG 的屬性,選擇 react-svg。這個庫讓你可以直接使用 SVG 元素,並對其進行詳細的控制。

  • react-fontawesome:

    如果你需要一個功能強大且多樣化的圖示庫,並且希望使用 Font Awesome 的完整功能,選擇 react-fontawesome。它支持大量的圖示和自定義選項,非常適合需要豐富圖示的應用。

react-icons 的 README

React Icons

React Icons

npm

Include popular icons in your React projects easily with react-icons, which utilizes ES6 imports that allows you to include only the icons that your project is using.

Installation (for standard modern project)

yarn add react-icons
# or
npm install react-icons --save

example usage

import { FaBeer } from "react-icons/fa";

function Question() {
  return (
    <h3>
      Lets go for a <FaBeer />?
    </h3>
  );
}

View the documentation for further usage examples and how to use icons from other packages. NOTE: each Icon package has it's own subfolder under react-icons you import from.

For example, to use an icon from Material Design, your import would be: import { ICON_NAME } from 'react-icons/md';

Installation (for meteorjs, gatsbyjs, etc)

Note This option has not had a new release for some time. More info https://github.com/react-icons/react-icons/issues/593

If your project grows in size, this option is available. This method has the trade-off that it takes a long time to install the package.

yarn add @react-icons/all-files
# or
npm install @react-icons/all-files --save

example usage

import { FaBeer } from "@react-icons/all-files/fa/FaBeer";

function Question() {
  return (
    <h3>
      Lets go for a <FaBeer />?
    </h3>
  );
}

Icons

Icon LibraryLicenseVersionCount
Circum IconsMPL-2.0 license1.0.0288
Font Awesome 5CC BY 4.0 License5.15.4-3-gafecf2a1612
Font Awesome 6CC BY 4.0 License6.5.22045
Ionicons 4MIT4.6.3696
Ionicons 5MIT5.5.41332
Material Design iconsApache License Version 2.04.0.0-98-g9beae745bb4341
TypiconsCC BY-SA 3.02.1.2336
Github Octicons iconsMIT18.3.0264
FeatherMIT4.29.1287
LucideISCv5.1.0-6-g438f572e1215
Game IconsCC BY 3.012920d6565588f0512542a3cb0cdfd36a497f9104040
Weather IconsSIL OFL 1.12.0.12219
DeviconsMIT1.8.0192
Ant Design IconsMIT4.4.2831
Bootstrap IconsMIT1.11.32716
Remix IconApache License Version 2.04.2.02860
Flat Color IconsMIT1.0.2329
Grommet-IconsApache License Version 2.04.12.1635
HeroiconsMIT1.0.6460
Heroicons 2MIT2.1.3888
Simple IconsCC0 1.0 Universal12.14.03209
Simple Line IconsMIT2.5.5189
IcoMoon FreeCC BY 4.0 Licensed006795ede82361e1bac1ee76f215cf1dc51e4ca491
BoxIconsMIT2.1.41634
css.ggMIT2.1.1704
VS Code IconsCC BY 4.00.0.35461
Tabler IconsMIT3.2.05237
Themify IconsMITv0.1.2-2-g9600186352
Radix IconsMIT@radix-ui/react-[email protected]318
Phosphor IconsMIT2.1.19072
Icons8 Line AwesomeMIT1.3.11544

You can add more icons by submitting pull requests or creating issues.

Configuration

You can configure react-icons props using React Context API.

Requires React 16.3 or higher.

import { IconContext } from "react-icons";

<IconContext.Provider value={{ color: "blue", className: "global-class-name" }}>
  <div>
    <FaFolder />
  </div>
</IconContext.Provider>;
KeyDefaultNotes
colorundefined (inherit)
size1em
classNameundefined
styleundefinedCan overwrite size and color
attrundefinedOverwritten by other attributes
titleundefinedIcon description for accessibility

Migrating from version 2 -> 3

Change import style

Import path has changed. You need to rewrite from the old style.

// OLD IMPORT STYLE
import FaBeer from "react-icons/lib/fa/beer";

function Question() {
  return (
    <h3>
      Lets go for a <FaBeer />?
    </h3>
  );
}
// NEW IMPORT STYLE
import { FaBeer } from "react-icons/fa";

function Question() {
  return (
    <h3>
      Lets go for a <FaBeer />?
    </h3>
  );
}

Ending up with a large JS bundle? Check out this issue.

Adjustment CSS

From version 3, vertical-align: middle is not automatically given. Please use IconContext to specify className or specify an inline style.

Global Inline Styling

<IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>

Global className Styling

Component

<IconContext.Provider value={{ className: 'react-icons' }}>

CSS

.react-icons {
  vertical-align: middle;
}

TypeScript native support

Dependencies on @types/react-icons can be deleted.

Yarn

yarn remove @types/react-icons

NPM

npm remove @types/react-icons

Contributing

./build-script.sh will build the whole project. See also CI scripts for more information.

Development

yarn
cd packages/react-icons
yarn fetch  # fetch icon sources
yarn build

Add/Update icon set

First, check the discussion to see if anyone would like to add an icon set.

https://github.com/react-icons/react-icons/discussions/categories/new-icon-set

The SVG files to be fetched are managed in this file. Edit this file and run yarn fetch && yarn check && yarn build.

https://github.com/react-icons/react-icons/blob/master/packages/react-icons/src/icons/index.ts

Preview

Note The project is not actively accepting PR for the preview site at this time.

The preview site is the react-icons website, built in Astro+React.

cd packages/react-icons
yarn fetch
yarn build

cd ../preview-astro
yarn start

Demo

The demo is a Create React App boilerplate with react-icons added as a dependency for easy testing.

cd packages/react-icons
yarn fetch
yarn build

cd ../demo
yarn start

Why React SVG components instead of fonts?

SVG is supported by all major browsers. With react-icons, you can serve only the needed icons instead of one big font file to the users, helping you to recognize which icons are used in your project.

Related Projects

Licence

MIT

  • Icons are taken from the other projects so please check each project licences accordingly.