Documentation Index Fetch the complete documentation index at: https://mintlify.com/react-icons/react-icons/llms.txt
Use this file to discover all available pages before exploring further.
Frequently Asked Questions
Find answers to common questions about React Icons.
Installation & Setup
What version of React do I need?
React Icons works with React 16.3 and higher (any version that supports Context API). {
"peerDependencies" : {
"react" : "*"
}
}
The library is compatible with React 16, 17, 18, and 19.
Can I use React Icons with TypeScript?
Yes! React Icons includes native TypeScript support with complete type definitions. No additional @types package is needed: import { IconType } from "react-icons" ;
import { FaBeer } from "react-icons/fa" ;
type IconProps = {
icon : IconType ;
size ?: number ;
};
See the TypeScript guide for more details.
Does React Icons work with Next.js?
Yes! React Icons works perfectly with Next.js (both Pages Router and App Router). import { FaBeer } from "react-icons/fa" ;
export default function Home () {
return < h1 > Welcome < FaBeer /></ h1 > ;
}
Tree-shaking works automatically with Next.js’s bundler.
Can I use React Icons with Create React App?
Yes! React Icons works out of the box with Create React App. import { FaBeer } from "react-icons/fa" ;
function App () {
return < div >< FaBeer /></ div > ;
}
No additional configuration needed.
Yes! React Icons works seamlessly with Vite: import { FaBeer } from "react-icons/fa" ;
Vite’s built-in tree-shaking ensures optimal bundle sizes.
Why is my bundle size so large?
If you’re seeing a large bundle, you’re likely importing incorrectly: // ❌ Wrong - imports entire library (~2MB)
import * as Icons from "react-icons/fa" ;
// ✅ Correct - only imports needed icons
import { FaBeer , FaCoffee } from "react-icons/fa" ;
See the Performance guide for optimization tips.
How much do icons add to my bundle?
Each icon adds approximately 1-2 KB to your bundle:
1 icon ≈ 1-2 KB
10 icons ≈ 10-20 KB
100 icons ≈ 100-200 KB
With proper tree-shaking, you only pay for what you use.
Does React Icons support tree-shaking?
Yes! React Icons is designed for tree-shaking with ES6 modules. The package is configured with "sideEffects": false, enabling aggressive tree-shaking in modern bundlers. See the Tree-Shaking guide for details.
Should I use @react-icons/all-files?
Generally, no. The @react-icons/all-files package is outdated and has not been updated recently. Use the main react-icons package instead: It provides better tree-shaking and is actively maintained.
Yes! You can dynamically import icon modules: import { lazy , Suspense } from "react" ;
const FaBeer = lazy (() =>
import ( "react-icons/fa" ). then ( module => ({
default: module . FaBeer
}))
);
function App () {
return (
< Suspense fallback = { < div > Loading... </ div > } >
< FaBeer />
</ Suspense >
);
}
See Performance Optimization for more patterns.
Usage & Customization
How do I change icon size?
Use the size prop: // As number (pixels)
< FaBeer size = { 24 } />
// As string (any CSS unit)
< FaBeer size = "2em" />
< FaBeer size = "32px" />
< FaBeer size = "2rem" />
Or set globally with IconContext: < IconContext.Provider value = { { size: "2em" } } >
< FaBeer /> { /* All icons are 2em */ }
</ IconContext.Provider >
How do I change icon color?
Use the color prop or CSS: // Via prop
< FaBeer color = "red" />
< FaBeer color = "#61DAFB" />
// Via CSS color inheritance
< div style = { { color: "blue" } } >
< FaBeer /> { /* Inherits blue */ }
</ div >
// Via className
< FaBeer className = "text-blue-500" />
Can I use CSS classes with icons?
Yes! Use the className prop: < FaBeer className = "my-icon-class" />
With Tailwind CSS: < FaBeer className = "text-blue-500 hover:text-blue-700 w-6 h-6" />
With IconContext for global classes: < IconContext.Provider value = { { className: "global-icon-class" } } >
< FaBeer />
</ IconContext.Provider >
How do I add hover effects?
Use CSS or inline styles: // With CSS
< FaBeer className = "icon-hover" />
.icon-hover {
transition : color 0.2 s ;
}
.icon-hover:hover {
color : blue ;
}
Or with inline styles: const [ hover , setHover ] = useState ( false );
< FaBeer
onMouseEnter = { () => setHover ( true ) }
onMouseLeave = { () => setHover ( false ) }
style = { { color: hover ? "blue" : "black" } }
/>
Yes! Icons are SVG elements that can be animated: // CSS animation
< FaBeer className = "spin" />
@keyframes spin {
from { transform : rotate ( 0 deg ); }
to { transform : rotate ( 360 deg ); }
}
.spin {
animation : spin 2 s linear infinite ;
}
Or use animation libraries like Framer Motion: import { motion } from "framer-motion" ;
< motion.div
animate = { { rotate: 360 } }
transition = { { duration: 2 , repeat: Infinity } }
>
< FaBeer />
</ motion.div >
How do I use icons in buttons?
Icon Libraries
Which icon library should I use?
It depends on your project:
Font Awesome - Most comprehensive, 2,000+ icons
Material Design - For Material UI projects, 4,000+ icons
Heroicons - For Tailwind CSS projects, clean design
Lucide - Modern, beautiful, 1,500+ icons
Bootstrap Icons - For Bootstrap projects, 2,700+ icons
See the Icon Libraries Overview for comparisons.
Can I mix icons from different libraries?
Yes! You can import from multiple libraries: import { FaBeer } from "react-icons/fa" ;
import { MdHome } from "react-icons/md" ;
import { HiUser } from "react-icons/hi2" ;
function App () {
return (
< div >
< FaBeer />
< MdHome />
< HiUser />
</ div >
);
}
Each icon pack is independently tree-shakeable.
How do I find the right icon name?
Visit the official React Icons website to search and browse all available icons. Icon names follow a pattern:
Prefix + icon name: FaBeer, MdHome, HiUser
Variants use suffixes: FaRegStar (regular), HiOutlineHome (outline)
Are the icon packs kept up to date?
Yes, the React Icons team regularly updates icon packs to their latest versions. Check the VERSIONS file for current versions. You can request updates by opening an issue on GitHub.
Can I request a new icon pack?
Yes! Start a discussion proposing the new icon pack. Include:
Icon pack name and website
License (must be open source)
Number of icons
Use case
See Adding Icon Sets for details.
Server-Side Rendering (SSR)
Does React Icons work with SSR?
Yes! React Icons works with all SSR frameworks:
Next.js (Pages & App Router)
Remix
Gatsby
Astro with React
Icons render as static SVG on the server.
Do I need special configuration for Next.js App Router?
No special configuration needed. Icons work in both Client and Server Components: import { FaBeer } from "react-icons/fa" ;
export default function Page () {
return < h1 > Hello < FaBeer /></ h1 > ;
}
If using IconContext, mark the component as a Client Component: "use client" ;
import { IconContext } from "react-icons" ;
Accessibility
Icons can be made accessible using the title prop: // Decorative icon (hidden from screen readers)
< FaBeer aria-hidden = "true" />
// Meaningful icon (announced to screen readers)
< FaBeer title = "Beer" />
// Icon button
< button aria-label = "Grab a beer" >
< FaBeer aria-hidden = "true" />
</ button >
See the Accessibility guide for best practices.
Should I use aria-label with icons?
For interactive elements (buttons, links), use aria-label on the parent: // ✅ Correct
< button aria-label = "Delete" >
< FaTrash aria-hidden = "true" />
</ button >
// ❌ Wrong - aria-label on icon doesn't help
< button >
< FaTrash aria-label = "Delete" />
</ button >
Troubleshooting
Check that you:
Installed the package: npm install react-icons
Imported correctly: import { FaBeer } from "react-icons/fa"
Used the correct icon name (case-sensitive)
Try a simple test: import { FaBeer } from "react-icons/fa" ;
console . log ( FaBeer ); // Should be a function
Make sure you:
Don’t have @types/react-icons installed (conflicts with native types)
Are using a compatible TypeScript version (5.0+)
Have correct imports
Remove conflicting types: npm uninstall @types/react-icons
React Icons v3+ removed automatic vertical alignment. Add it back: // Global
< IconContext.Provider value = { { style: { verticalAlign: 'middle' } } } >
{ children }
</ IconContext.Provider >
// Per icon
< FaBeer style = { { verticalAlign: 'middle' } } />
See Migration from v2 to v3 for details.
Still Have Questions?
Troubleshooting Find solutions to common issues
GitHub Discussions Ask the community
GitHub Issues Report bugs or request features
Stack Overflow Search existing Q&A