What it is
Heroicons is a set of free, MIT-licensed high-quality SVG icons for UI development. It provides both outline and solid styles, optimized for modern web applications.
Heroicons can be used as React components, Vue components, or inline SVGs. They are customizable via size, color, stroke, and other SVG attributes.
Installation
npm install @heroicons/reactGetting started
The smallest useful thing you can do with it, and what each part means.
import { AcademicCapIcon } from '@heroicons/react/outline';
function App() {
return <AcademicCapIcon className='h-6 w-6 text-blue-500' />;
}import { AcademicCapIcon } from '@heroicons/react/solid';
function App() {
return <AcademicCapIcon className='h-6 w-6 text-green-500' />;
}Advanced usage
Where the library earns its place over a simpler alternative.
<AcademicCapIcon className='h-12 w-12 text-red-600' /><AcademicCapIcon className='h-6 w-6 text-blue-500 animate-spin' /><svg xmlns='http://www.w3.org/2000/svg' class='h-6 w-6' fill='none' viewBox='0 0 24 24' stroke='currentColor'>
<path stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 14l9-5-9-5-9 5 9 5z' />
</svg>Errors and fixes
The failures you are most likely to hit, and what actually resolves them.
- Icon not displayed
- Ensure the component or SVG is correctly imported and rendered in your project.
- Incorrect size or color
- Check the CSS classes or SVG attributes applied to the icon.
- Bundle size too large
- Use tree-shaking or import individual icons instead of the entire package.
Best practices
- Import only the icons you need to reduce bundle size.
- Use Tailwind CSS classes for consistent sizing and coloring.
- Prefer React/Vue components for ease of integration and maintainability.
- Use solid or outline variants consistently to match your UI design.
- Combine with accessibility attributes like `aria-label` or `title` for screen readers.
Background
Why it exists, and what it was reacting to.
Heroicons was created by the makers of Tailwind CSS to provide a cohesive and visually appealing set of icons that integrate seamlessly with Tailwind-based projects. It focuses on simplicity, scalability, and clarity, making it popular among frontend developers.
