react-feather と react-icons は、React アプリケーションでベクター形式のアイコンを簡単に使用するためのライブラリです。react-feather は Feather Icons の公式 React 実装であり、一貫したスタイルを持つ軽量なアイコンセットを提供します。一方、react-icons は複数の人気アイコンセット(Feather Icons を含む)を単一のパッケージで利用可能にし、必要なアイコンだけを個別にインポートできる柔軟性を持っています。両方とも SVG ベースで、CSS によるスタイリングが容易です。
React アプリでアイコンを使うとき、react-feather と react-icons はよく検討される選択肢です。どちらも SVG アイコンを React コンポーネントとして提供しますが、アーキテクチャや使い勝手には明確な違いがあります。実際の開発現場での判断材料になるよう、技術的な観点から詳しく見ていきましょう。
react-feather は Feather Icons 専用のラッパーです。1つの統一されたビジュアル言語(細めの線、丸みのある角)しか提供しません。
// react-feather
import { Heart, Star } from 'react-feather';
function App() {
return (
<div>
<Heart color="red" size={24} />
<Star fill="gold" size={20} />
</div>
);
}
react-icons は複数のアイコンセットを統合しています。Feather だけでなく、FontAwesome、Material Icons、Lucide など 20 種類以上のセットを利用可能です。
// react-icons
import { FiHeart } from 'react-icons/fi'; // Feather
import { FaStar } from 'react-icons/fa'; // FontAwesome
function App() {
return (
<div>
<FiHeart color="red" size={24} />
<FaStar color="gold" size={20} />
</div>
);
}
💡 注意:
react-iconsでは各アイコンセットごとにサブパス(例:/fi,/fa)を指定してインポートします。これにより、未使用のアイコンはバンドルに含まれません。
react-feather は全アイコンを一度にインポートする方式を採用しています。たとえ1つだけ使ったとしても、全アイコンのコードがバンドルに含まれる可能性があります(ただし、最新のビルドツールで tree-shaking が効く場合もあります)。
// 全アイコンが潜在的にバンドル対象になる
import { Camera, Settings } from 'react-feather';
react-icons は「1アイコン=1モジュール」の設計です。使うアイコンだけを個別にインポートするため、不要なコードがバンドルに混入することはありません。
// 必要最小限のコードのみがバンドルされる
import { MdCamera } from 'react-icons/md';
import { IoSettings } from 'react-icons/io';
この違いは、特に大規模アプリやパフォーマンスが重要なプロジェクトで顕著になります。
両方とも共通の props(size, color, className など)をサポートしており、基本的なスタイリングはほぼ同じように記述できます。
// どちらも同じ props を受け付ける
<Icon size={32} color="#333" className="custom-icon" />
ただし、react-feather は strokeWidth や strokeLinecap といった SVG 固有の属性を直接渡せる点が特徴です。Feather アイコンの線の太さなどを細かく調整したい場合に便利です。
// react-feather での詳細制御
<Heart strokeWidth={1.5} strokeLinecap="round" />
一方、react-icons は各アイコンセットの元のデザインを尊重しており、SVG 属性の直接操作は推奨されていません。代わりに、CSS や style prop での調整が一般的です。
公式ドキュメントおよび npm ページを確認したところ、両ライブラリとも現在もアクティブにメンテナンスされています。非推奨(deprecated)の通知はなく、新規プロジェクトでの使用に問題はありません。
ただし、react-feather は Feather Icons 自体の更新頻度に依存します。一方、react-icons は複数のソースを統合しているため、特定のアイコンセットが更新されればすぐに追随可能です。
react-featherreact-iconsreact-icons| 項目 | react-feather | react-icons |
|---|---|---|
| アイコンセット | Feather のみ | 20+ セット(Feather 含む) |
| バンドル戦略 | 全アイコンが対象(tree-shaking 依存) | 使用アイコンのみ |
| インポート方法 | import { Icon } from 'react-feather' | import { FiIcon } from 'react-icons/fi' |
| 詳細 SVG 制御 | 可能(strokeWidth など) | 非推奨(CSS 推奨) |
| ユースケース | 単一デザイン言語のプロジェクト | 多様なアイコンニーズがあるプロジェクト |
react-featherreact-iconsどちらを選んでも、React でのアイコン管理は十分に成熟した解決策です。プロジェクトのスケール、デザイン要件、パフォーマンス目標を照らし合わせて判断してください。
react-icons は、複数のアイコンセット(Feather、FontAwesome、Material Design など)を一つのインターフェースで扱いたい場合に最適です。必要に応じてアイコンを個別にインポートできるため、バンドルサイズを抑えつつ多様なデザインニーズに対応できます。大規模アプリやデザインガイドラインが複雑なプロジェクトで特に有効です。
react-feather は、Feather Icons のみを使用し、シンプルで一貫性のあるデザインが必要なプロジェクトに向いています。依存関係が少なく、API も最小限のため、軽量さとシンプルさを重視する場合に適しています。ただし、他のアイコンセットを使いたい場合は別のライブラリを追加する必要があります。
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.
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';
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>
);
}
You can add more icons by submitting pull requests or creating issues.
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>;
| Key | Default | Notes |
|---|---|---|
color | undefined (inherit) | |
size | 1em | |
className | undefined | |
style | undefined | Can overwrite size and color |
attr | undefined | Overwritten by other attributes |
title | undefined | Icon description for accessibility |
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.
From version 3, vertical-align: middle is not automatically given. Please use IconContext to specify className or specify an inline style.
<IconContext.Provider value={{ style: { verticalAlign: 'middle' } }}>
className StylingComponent
<IconContext.Provider value={{ className: 'react-icons' }}>
CSS
.react-icons {
vertical-align: middle;
}
Dependencies on @types/react-icons can be deleted.
yarn remove @types/react-icons
npm remove @types/react-icons
./build-script.sh will build the whole project. See also CI scripts for more information.
yarn
cd packages/react-icons
yarn fetch # fetch icon sources
yarn build
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
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
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
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.
MIT