A professional, flexible, and type-safe icon component system for React and Next.js projects, built with Tailwind CSS for easy styling.
This isn't just another icon library. It's a headless component system designed for developers who value control, consistency, and performance. The core principle is that styling should be fully managed by utility classes, providing a seamless experience with Tailwind CSS.
- β
Truly Headless Styling: A single
classNameprop intelligently styles both the container and the SVG icon itself. - π Optimized Package Size: The library is structured for tree-shaking. You only import the icons you use, which keeps your final application bundle small and fast.
- β¨ Flexible & Composable: Includes standard SVG icons and special components like
Alphabetfor dynamic text-based icons. - π§ Fully Customizable: Easily add your own SVG icons or remove unused ones to keep the library perfectly tailored to your project's needs.
- π Zero Dependencies: Lightweight with no external runtime dependencies.
npm install own-svg-iconsImport any icon component and use it directly in your React/Next.js application.
import { GitHub, Terminal, Alphabet } from 'own-svg-icons';
function MyComponent() {
return (
<div className="flex items-center space-x-4">
<GitHub className="h-10 w-10 text-gray-800" />
<Terminal className="h-10 w-10 text-blue-500" />
<Alphabet
letter="A"
className="h-10 w-10 rounded-full bg-red-500 text-white"
/>
</div>
);
}The power of this library comes from its intelligent class parser. You pass all your Tailwind CSS classes to a single className prop, and the component does the rest.
π·οΈ How it Works
The className prop is split internally:
- Size, layout, and background classes (
h-10,w-10,bg-red-500) are applied to the outer<span>wrapper. - Text and font color classes (
text-blue-500,text-white) are applied directly to the inner<svg>or text element.
This allows for intuitive and powerful styling with minimal code.
π·οΈ Example: Sizing and Coloring
<Home className="h-12 w-12 text-green-500" />This library is designed to be your own. You can easily add or remove icons to fit your project's specific needs.
-
Add the SVG Component: Create a new
.tsxfile insrc/icons/(e.g.,src/icons/MyIcon.tsx). -
Use the Wrapper:
import React from 'react'; import { IconWrapper } from '../lib/IconWrapper'; export function MyIcon({ className }: { className?: string }) { return ( <IconWrapper className={className}> <path d="..." /> {/* Paste your SVG <path> elements here */} </IconWrapper> ); }
-
Export the Icon: In
src/index.ts, add:export * from './icons/MyIcon';
-
Rebuild the Library:
npm run build
Delete the icon files from src/icons/ and remove their exports from src/index.ts. Then run:
npm run build<GitHub /><Home /><Icon />(a generic icon)<Layer /><Settings /><Terminal /><User />
Renders the provided letter inside a container using the same styling logic as the SVG icons.
| Prop | Type | Required | Description |
|---|---|---|---|
className |
string |
No | Tailwind utility classes to style the icon. |
letter |
string |
Yes | (Alphabet only) The character to display. |
We welcome contributions! Here's how to get started:
git clone https://github.com/DevRGD/own-svg-icons.git
cd own-svg-iconsnpm installnpm testnpm run lint
npm run formatnpm run buildThen push your feature branch and open a PR.