React Icons: How to Add Icons to a React App
How do you add icons to a React app?
The easiest way to add icons to a React app is to install an icon package from npm, such as fmicon-react, and import each icon as a component. You write <Lock size={24} /> like any other component. Modern bundlers like Vite and webpack then keep only the icons you import.
The first React app I shipped had icons copied in as loose SVG files. Within a month there were three slightly different trash icons and nobody knew which one was right. Switching to one icon package fixed that in an afternoon.
Here's the good news. Adding React icons the clean way is simpler than it sounds. This guide walks you through it step by step, with code you can paste straight into your project.
What is a React icon library?
A React icon library is an npm package where every icon is a React component. Each component renders an inline SVG, so you can set its size, colour and label with props instead of editing files.
Before components, many teams used icon fonts, where each icon was a letter in a custom font. That worked, but it had problems with blurry edges and screen readers. GitHub wrote about this in 2016, when it moved its Octicons from an icon font to SVG. The team said SVG icons rendered more crisply and were easier to make accessible.
Today, almost every popular React icon set ships as SVG components. Lucide grew out of the Feather icons project. Heroicons comes from Tailwind Labs, the team behind Tailwind CSS. fmicon adds 891 icons in 8 styles, from clean linear icons to soft glass icons.
How to install React icons, step by step
You install React icons with one npm command and then import the icons you need. The whole setup takes about two minutes. You've got this.
Step 1: Install the package
npm install fmicon-react
It works the same with pnpm, Yarn or Bun. The package supports React 17 and newer, which includes React 18 and 19.
Step 2: Import an icon
import { Lock } from "fmicon-react";
export function LoginButton() {
return (
<button>
<Lock size={18} />
Log in
</button>
);
}
Component names follow the icon's name in PascalCase. So home-2 becomes Home2 and arrow-circle-right becomes ArrowCircleRight. You can search every name on the icon browser, and each icon page, like the lock icon, shows its ready-made React code.
Step 3: Pick a style
<Lock variant="bold" />
This part is actually really easy. One variant prop switches between linear, outline, bold, bulk, twotone, broken, glass and duotone. A neat trick is linear for idle states and bold for the selected one, like an active tab.
How do you change the size and colour of React icons?
You change the size of a React icon with the size prop and its colour with the color prop or plain CSS. By default, fmicon icons are 24 px and take the text colour of their parent.
<Lock size={20} color="#1265ec" strokeWidth={1.5} />
The text colour default is the part I like most. Because the icons use currentColor, an icon inside a red error message turns red on its own. A link icon follows the link's hover colour. You write less code and the colours never drift apart.
Line styles also take a strokeWidth prop. A thinner stroke, like 1 or 1.25, looks calm at large sizes. A thicker stroke, like 2, reads better at 16 px (about 4 mm on a typical laptop screen).
How do you keep React icons from bloating your bundle?
You keep React icons light by importing only the icons you use. Bundlers such as Vite, webpack and Rollup remove unused exports through tree shaking, so 891 icons in the package does not mean 891 icons in your app.
The webpack documentation describes tree shaking as removing dead code, and it relies on ES module import and export syntax. fmicon-react ships every icon as its own ES module, so this works out of the box.
If you want to be extra sure, or your setup does not tree shake, import the single file directly:
import { Lock } from "fmicon-react/icons/lock";
In my tests, a typical linear icon adds well under 1 KB once gzipped. Ten icons barely show up in a bundle report. Our SVG vs PNG comparison has the exact file sizes.
How do you make React icons accessible?
Decorative icons should be hidden from screen readers, and icons that carry meaning need a text name. fmicon-react hides icons with aria-hidden by default and adds a label when you pass a title prop.
// Decorative: the button text already says "Delete"
<button><Trash /> Delete</button>
// Icon-only: give the button a name
<button aria-label="Delete"><Trash /></button>
// Standalone meaningful icon
<Warning2 title="Warning" />
Most people are surprised to learn how often this goes wrong. WebAIM's yearly study of the top one million home pages keeps listing empty buttons and empty links among the most common accessibility errors. An icon button with no name is exactly that. Our accessible icons guide covers contrast and tap sizes too.
Which React icon library should you choose?
The best React icon library is the one whose style fits your product and whose licence fits your project. Every option below is a solid choice. They just shine in different situations.
| Option | What it is | It shines when |
|---|---|---|
| fmicon-react | 891 icons, 8 styles, MIT licence | You want several styles of one icon, including glass and duotone |
| Lucide React | A large line icon set, ISC licence | You want a single clean line style |
| Heroicons | Icons from Tailwind Labs, MIT licence | Your app is built with Tailwind CSS |
| react-icons | Many popular icon packs in one package | You need icons from several different sets |
| SVGR | A tool that turns your SVG files into components | Your designer draws custom icons |
Whatever you pick, stick to one main set. Mixing sets is how you end up with three different trash icons, like I did.
Do the same icons work in React Native, Vue and Svelte?
Yes, fmicon publishes the same icons for React Native, Vue 3 and Svelte, with the same names and props. That makes it easy to share a design language between a web app and a mobile app.
- React Native:
npm i fmicon-react-native react-native-svg, see the React Native docs - Vue 3:
npm i fmicon-vue, see the Vue docs - Svelte:
npm i fmicon-svelte, see the Svelte docs - No framework:
npm i fmicon, see the vanilla JS docs
What this means for your next project
For most React projects, one icon package plus three habits is all you need. Here's exactly what to do:
- Install one icon package and use it everywhere.
- Let icons inherit text colour instead of hard-coding colours.
- Name every icon-only button with
aria-label. - Use one style for idle states and a filled style for active states.
Once you do this once, it becomes second nature.
React icons, done the easy way
React icons work best as components: install a package, import what you need, and let props handle size, colour and labels. Your bundle stays small and your icons stay consistent. To try it now, run npm i fmicon-react, then pick icons from the free icon library or read the full React docs.
Frequently Asked Questions
Do React icon packages work with Next.js?
Yes, React icon packages that ship standard ES modules work with Next.js, in both the App Router and the Pages Router. fmicon-react icons are plain components that render SVG, so you import them in any page or component the same way you would in a Vite or Create React App project.
Can you use SVG files directly in React?
Yes, you can use SVG files directly in React. The simplest way is an img tag pointing to the file. To change colour or size with props, paste the SVG markup into a component, use a tool like SVGR to convert it, or install a ready-made icon package such as fmicon-react.
How do you change a React icon's colour on hover?
You change a React icon's colour on hover by changing the CSS color of its parent. Icons drawn with currentColor, like fmicon-react, follow the parent's text colour. So a rule such as button:hover with color set to blue turns the icon blue too, with no extra props or JavaScript.
Should you use an icon font in React?
No, most React projects should use SVG icon components instead of an icon font. SVG icons render more sharply, load only the icons you use, and are easier to label for screen readers. GitHub switched its Octicons from a font to SVG in 2016 for these reasons.
Are React icons free for commercial use?
Many React icon libraries are free for commercial use, but the licence decides. fmicon-react, Heroicons and Lucide all use permissive open-source licences such as MIT or ISC, which allow commercial projects. Always read the licence file in the package before you ship, especially in bundles that combine several icon sets.

