Best Practices

Handling & Organizing Icons in React: Folder Structure Best Practices

9 min read

Learn how to effectively organize and manage icons in React projects with scalable folder structures and best practices.

Icons are small but mighty. In modern web development, especially in React applications, icons play a critical role in user interfaces — enhancing navigation, improving readability, and reinforcing brand consistency. However, as your project grows, the way you organize and manage these icons becomes increasingly important.

Whether you're building a small UI library or managing a multi-team enterprise application, having a scalable folder structure and icon management strategy can save countless hours of development time. In this post, we'll explore how to effectively handle and organize icons in React, including folder structure best practices, reusable component strategies, and how to manage third-party vs. custom icons.

Why Icon Organization Matters

Before diving into folder structures, let's understand why icon management deserves special attention:

  • Maintainability: Poorly organized icons can clutter your codebase, making it hard to find or reuse icons later.
  • Scalability: A scalable strategy supports hundreds of icons without degrading performance or developer experience.
  • Performance: Proper usage of SVGs and imports ensures that unused icons don't bloat your final bundle.
  • Reusability: Clean abstractions promote icon reuse, reducing code duplication and inconsistencies.

Common Types of Icons in Code Projects

Icons in React projects typically fall into three categories:

  1. Third-party icon libraries (e.g., Font Awesome, Material Icons, Feather Icons via react-icons)
  2. Custom SVG icons created in-house or from designers
  3. Icon components (wrappers or themed variants of raw icons)

Each category may have different requirements, but a smart folder structure can help unify how they're managed.

Basic Folder Structure for Icon Management

A well-organized folder structure might look like this:

/src
/components
/icons
/custom
ArrowLeft.tsx
ArrowRight.tsx
LogoIcon.tsx
/third-party
Material.ts
FontAwesome.ts
index.ts

Explanation:

  • /icons: A dedicated folder for all icon-related components and SVGs.
  • /custom: SVG icons that have been converted into React components.
  • /third-party: Grouped imports from libraries like react-icons.
  • index.ts: Centralized exports for easy access and lazy loading if needed.

Step-by-Step: Creating Custom Icon Components

Let's say you receive raw SVG files from your designer. Here's how to manage and use them properly:

Step 1: Convert SVG to React Component

You can use tools like SVGR or plugins in tools like Figma to export SVGs as JSX.

Here's an example:

// src/components/icons/custom/ArrowLeft.tsx
const ArrowLeft = (props: React.SVGProps<SVGSVGElement>) => (
<svg width="24" height="24" viewBox="0 0 24 24" {...props}>
<path d="M15 6l-6 6 6 6" stroke="currentColor" strokeWidth="2" fill="none" />
</svg>
);
export default ArrowLeft;

Step 2: Standardize the API

Ensure all icon components accept standard SVGProps so they're easily styled or animated.

type IconProps = React.SVGProps<SVGSVGElement>;
const ArrowRight = (props: IconProps) => (
<svg viewBox="0 0 24 24" {...props}>
<path d="M9 6l6 6-6 6" stroke="currentColor" strokeWidth="2" fill="none" />
</svg>
);

Centralized Icon Exports with Index File

Your index.ts acts as a centralized registry of available icons:

// src/components/icons/index.ts
export { default as ArrowLeft } from './custom/ArrowLeft';
export { default as ArrowRight } from './custom/ArrowRight';
export { FaHome } from 'react-icons/fa';
export { MdSettings } from 'react-icons/md';

This allows you to import icons like this throughout your project:

import { ArrowLeft, MdSettings } from '@/components/icons';

This improves discoverability and ensures consistency across the codebase.

Organizing Third-Party Icons

Third-party icons can clutter your code if not managed thoughtfully. Here's how to streamline their usage:

Option 1: Wrap Third-Party Icons

Instead of importing directly from react-icons/fa, create a wrapped version in your /third-party folder:

// src/components/icons/third-party/Material.ts
import { MdSettings, MdHome } from 'react-icons/md';
export const SettingsIcon = (props: React.SVGProps<SVGSVGElement>) => (
<MdSettings {...props} />
);
export const HomeIcon = (props: React.SVGProps<SVGSVGElement>) => (
<MdHome {...props} />
);

This allows future customization (e.g., styling, accessibility, class names) without hunting down every usage.

Advanced Folder Structures for Large-Scale Projects

As your app scales, consider categorizing icons by feature or usage:

/icons
/custom
/navigation
Back.tsx
Next.tsx
/brand
Logo.tsx
Wordmark.tsx
/third-party
/material
...
/fontawesome
...

Benefits:

  • Logical grouping (e.g., brand, navigation, alerts)
  • Faster navigation and retrieval
  • Easier onboarding for new developers

Pro Tips for Icon Handling

1. Use Tree-Shakable Imports

Avoid importing all icons from libraries like react-icons. Always import only what you need:

import { FaUser } from 'react-icons/fa'; // Good
import * as FaIcons from 'react-icons/fa'; // Bad: not tree-shakable

2. Avoid Icon Fonts

SVG icons (inline or component-based) are more accessible, flexible, and better for performance than icon fonts.

3. Create a Generic Icon Component

You can build a wrapper that standardizes all icons for size, color, and accessibility:

interface IconWrapperProps extends React.SVGProps<SVGSVGElement> {
icon: React.ElementType;
}
const Icon = ({ icon: IconComponent, ...props }: IconWrapperProps) => (
<IconComponent width="24" height="24" aria-hidden="true" {...props} />
);
// Usage
<Icon icon={ArrowLeft} className="text-blue-500" />

This makes it easy to swap or style icons dynamically.

4. Document Your Icon System

Use Storybook or a custom internal documentation page to display available icons. This promotes reuse and design consistency.

Managing Icons in Design Systems

If you're working within a design system or UI library:

  • Define a clear naming convention (e.g., IconChevronLeft, IconAlertWarning)
  • Prefix all custom icons for clarity and versioning
  • Consider distributing icons as part of your component library

Common Mistakes to Avoid

  • ❌ Storing raw SVGs in multiple folders without conversion
  • ❌ Duplicating the same icon across components
  • ❌ Hardcoding size, color, or margin inside SVG components
  • ❌ Importing entire icon sets when only a few icons are needed
  • ❌ Using inconsistent names like Arrow_Left, arrowLeft, leftArrow

Stick with PascalCase (ArrowLeft) and avoid underscores or inconsistent casing for maximum clarity.

Summary: Best Practices Checklist

  • ✅ Use a dedicated /icons folder with custom and third-party subfolders
  • ✅ Convert SVGs to React components with reusable props
  • ✅ Export icons via a centralized index.ts for discoverability
  • ✅ Wrap third-party icons for customization flexibility
  • ✅ Categorize icons by purpose in large projects
  • ✅ Document available icons and usage guidelines
  • ✅ Avoid icon fonts and non-tree-shakable imports
  • ✅ Keep icon naming consistent and semantic

Final Thoughts

Handling icons in React is more than just importing and placing them in your JSX. A thoughtful approach to folder structure, component wrapping, and naming conventions can dramatically improve the scalability and maintainability of your application. With these best practices, your icon management will be cleaner, faster, and more efficient — no matter how big your project becomes.

Now go ahead — give your icons the structure they deserve.