font-awesome、heroicons、material-icons、react-fontawesome、react-icons、remixicon-react は、Web アプリケーションでアイコンを表示するための npm パッケージです。これらのパッケージは、アイコンの提供方法(SVG コンポーネント vs Web フォント)、React との統合度、カスタマイズ性、およびメンテナンス状況において大きく異なります。特に、font-awesome と material-icons は Web フォントベースのパッケージであり、React 向けのコンポーネントライブラリとしては非推奨です。一方、react-fontawesome、heroicons、react-icons、remixicon-react は SVG を React コンポーネントとして提供し、ツリーシェイキングや型安全性といった現代的なフロントエンド開発要件を満たしています。
フロントエンド開発でアイコンを扱う際、単に「見栄え」だけでなく、バンドルサイズ、TypeScript サポート、カスタマイズ性、メンテナンス状況など、多くの技術的要素が選定に影響します。この記事では、代表的な6つの npm パッケージについて、実際のコード例を交えながら深く比較します。
まず重要な前提として、font-awesome(npm パッケージ名)と material-icons は、React 向けのコンポーネントライブラリとしては非推奨または用途が異なることに注意が必要です。
font-awesome: このパッケージは Font Awesome の CSS/フォントファイルを提供するもので、React コンポーネントではありません。公式ドキュメントでも、React での使用には @fortawesome/react-fontawesome を使うよう明記されています。material-icons: Google 公式の Material Icons フォントをインストールするためのパッケージであり、SVG コンポーネントではなく Web フォントベースです。そのため、React での柔軟なスタイル制御や SSR 対応に制限があります。これらのパッケージは、新規 React プロジェクトでは直接使用すべきではありません。代わりに、それぞれ対応する React 専用ラッパー(react-fontawesome や react-icons 内の Material Icons)を利用すべきです。
アイコンライブラリは大きく2種類に分けられます:
SVG コンポーネントベース(例: heroicons, react-icons, remixicon-react)
Web フォントベース(例: font-awesome + CSS, material-icons)
<i class="fas fa-user"></i> のような HTML 要素で表示React プロジェクトでは、SVG コンポーネントベースが圧倒的に推奨されます。
react-fontawesome(Font Awesome の React 専用ラッパー)Font Awesome のアイコンを React コンポーネントとして使うには、react-fontawesome と個別のアイコンセット(例: @fortawesome/free-solid-svg-icons)を組み合わせます。
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUser } from '@fortawesome/free-solid-svg-icons';
function App() {
return <FontAwesomeIcon icon={faUser} size="lg" color="blue" />;
}
size, color, spin などの props でカスタマイズ可能heroicons(Tailwind CSS 公式アイコン)SVG パスを直接 React コンポーネントとしてエクスポート。シンプルで軽量。
import { UserIcon } from '@heroicons/react/24/outline';
function App() {
return <UserIcon className="w-6 h-6 text-blue-500" />;
}
24/outline, 24/solid, 20/solid など、サイズとスタイルごとにパスが分かれているclassName で Tailwind CSS クラスを直接適用可能material-icons(Web フォント版 — 非推奨)Google 公式の Web フォントを使う方法。React では不向き。
// ❌ 非推奨: Web フォント依存、SSR で FOUC 発生の可能性
import 'material-icons/iconfont/material-icons.css';
function App() {
return <i className="material-icons">account_circle</i>;
}
✅ 代わりに
react-icons経由で Material Icons を使うのがベストプラクティス(後述)。
react-icons(統合アイコンライブラリ)複数のアイコンセット(Fa, Io, Md, Ri など)を1つのインターフェースで提供。
import { FaUser, MdAccountCircle, RiUser3Fill } from 'react-icons/all';
function App() {
return (
<div>
<FaUser size="24px" color="red" />
<MdAccountCircle size={24} className="text-green-500" />
<RiUser3Fill style={{ width: '24px', height: '24px' }} />
</div>
);
}
size, color, className, styleremixicon-react(Remix Icon の React 専用版)Remix Icon の SVG を React コンポーネント化したもの。
import { User3Fill } from 'remixicon-react';
function App() {
return <User3Fill size="24" color="#3b82f6" />;
}
size と color props で基本カスタマイズUser3Fill)| パッケージ | 色変更 | サイズ変更 | 追加スタイル | 型安全性 |
|---|---|---|---|---|
react-fontawesome | ✅ (color) | ✅ (size or className) | ✅ (className, style) | ✅ |
heroicons | ✅ (className/style) | ✅ (className/style) | ✅ (className, style) | ✅ |
material-icons (Web font) | ❌ (CSS only) | ❌ (CSS only) | ⚠️ (CSS 依存) | ❌ |
react-icons | ✅ (color) | ✅ (size) | ✅ (className, style) | ✅ |
remixicon-react | ✅ (color) | ✅ (size) | ✅ (style) | ✅ |
heroicons は Tailwind CSS ユーザー向けに最適化されており、className での制御が自然です。一方、react-icons や react-fontawesome は汎用的な props を提供し、CSS-in-JS や styled-components との相性も良いです。
heroicons, remixicon-react, react-fontawesome: 使ったアイコンだけがバンドルされる(tree-shakable)react-icons: 同様に tree-shakable。ただし、内部で各アイコンセットをサブディレクトリに分けており、import パスに注意font-awesome (CSS版), material-icons (Web font): 全アイコンがフォントファイルとして読み込まれるため、初期ロードが重い特にモバイル向けやパフォーマンス重視のアプリでは、SVG コンポーネントベースの選択が必須です。
heroicons が最も自然に統合できます。
import { BellIcon } from '@heroicons/react/24/outline';
function NotificationButton() {
return (
<button className="p-2 rounded-full hover:bg-gray-100">
<BellIcon className="w-5 h-5 text-gray-700" />
</button>
);
}
react-icons が最適です。
import { FaGithub, FiTwitter, AiFillLinkedin } from 'react-icons/all';
function SocialLinks() {
return (
<div className="flex space-x-4">
<FaGithub size={20} />
<FiTwitter size={20} />
<AiFillLinkedin size={20} />
</div>
);
}
react-fontawesome を使って段階的に移行。
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCoffee, faCode } from '@fortawesome/free-solid-svg-icons';
function Features() {
return (
<div>
<FontAwesomeIcon icon={faCoffee} className="mr-2" />
<FontAwesomeIcon icon={faCode} className="ml-2" />
</div>
);
}
font-awesome パッケージを React で直接使う → CSS ベースのため、SSR やスタイル制御で問題が起きやすいmaterial-icons を Web フォントとして使う → アイコン名が文字列のため型安全でなく、バンドルも重いこれらは、必ず react-fontawesome や react-icons 経由で使うべきです。
| パッケージ | 推奨シナリオ | 注意点 |
|---|---|---|
react-fontawesome | 既に Font Awesome を使っているプロジェクト、豊富なアイコンが必要 | 別途アイコンセットの npm パッケージが必要 |
heroicons | Tailwind CSS ユーザー、シンプルでモダンなデザイン | アイコン数は他より少ない |
material-icons | 新規プロジェクトでは非推奨 | Web フォントベースのため React に不向き |
react-icons | 複数のアイコンセットを1つで管理したい、柔軟性重視 | パッケージが大きめだが、ツリーシェイキングで解決 |
remixicon-react | Remix Icon のデザインが気に入っている場合 | コミュニティ規模は react-icons より小さい |
font-awesome (CSS版) | React プロジェクトでは使用禁止 | React コンポーネントではない |
heroicons(Tailwind ユーザー)か react-icons(汎用性重視)が安全牌react-fontawesome で移行font-awesome や material-icons をそのまま React で使うこと — これらは Web フォント用パッケージであり、React の宣言的 UI モデルと相性が悪いアイコンは小さなUI要素ですが、選定ミスは長期的な技術的負債になります。パフォーマンス、保守性、開発体験のバランスを考えて、適切なパッケージを選びましょう。
複数のアイコンセット(Font Awesome, Ionicons, Material Design Icons, Remix Icon など)を1つの統一されたインターフェースで利用したい場合に最適です。個々のアイコンを個別に import でき、ツリーシェイキングによるバンドル最適化が可能です。汎用性が高く、デザインシステムをまだ固定していないプロジェクトや、特定のアイコンセットに縛られたくない場合に非常に有用です。
font-awesome パッケージは Web フォント(CSS/フォントファイル)を提供するものであり、React コンポーネントではありません。React プロジェクトで Font Awesome を使いたい場合は、代わりに react-fontawesome を使用してください。このパッケージは新規プロジェクトでの使用を避けるべきです。
Tailwind CSS を使用しているプロジェクトや、シンプルで一貫性のあるデザインシステムを求める場合に最適です。アイコンは SVG コンポーネントとして提供され、className で Tailwind クラスを直接適用できるため、開発体験が非常にスムーズです。ただし、アイコンの総数は他のライブラリに比べて少ないため、多様なアイコンが必要なケースでは物足りないかもしれません。
material-icons パッケージは Google 公式の Material Icons Web フォントをインストールするもので、React 向けのコンポーネントライブラリではありません。アイコン名を文字列で指定する必要があり型安全性に欠け、全アイコンがフォントファイルとして読み込まれるためバンドルサイズも大きくなります。新規 React プロジェクトでは使用せず、代わりに react-icons 経由で Material Icons を利用することを推奨します。
既に Font Awesome のアイコンセットに依存しているプロジェクトや、豊富なアイコンバリエーション(Regular, Solid, Brands など)が必要な場合に適しています。SVG コンポーネントとして提供され、size や color などの props でカスタマイズ可能で、ツリーシェイキングにも対応しています。ただし、アイコンごとに個別の npm パッケージ(例: @fortawesome/free-solid-svg-icons)を追加インストールする必要があります。
Remix Icon のデザインが好みで、そのアイコンセットを React コンポーネントとして使いたい場合に適しています。SVG ベースで size や color props によるカスタマイズが可能で、TypeScript サポートも含まれています。ただし、コミュニティ規模やドキュメントの充実度は react-icons や heroicons に比べるとやや劣る可能性があるため、長期的なメンテナンス観点で検討が必要です。
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