Your new favorite way to manage icons for your Vite, NextJS projects without icon libraries!
Based on my blog post on Why you might not need an icon library. Built with ๐ฆ Rust, โก๏ธ designed for speed, ๐ฆ made for developers who hate icon library bloat.
Stop installing bloated icon libraries. All you need is icones.js.org or your designer's Figma icon pack and paste them into your project with surgical precision.
What Makes It Special โจ
iconmate
and let it guide you# Install
npm install -g iconmate
# Run inside your project ๐
iconmate
> ๐ Folder (src/assets/icons/) # Enter
> โจ Preset # Choose react
> ๐ Icon # heroicons:heart
> ๐ Name # Heart
โจ That's it. The interactive CLI guides you through adding icon to your project!
// ๐ Then, you can just easily use any icon on your project like this!
import { IconHeart } from "@/assets/icons";
function MyApp() {
return <IconHeart />;
}
You can also add sensible defaults by passing flags:
iconmate --folder src/components/Icons/ --folder src/components/icons
iconmate --folder src/components/Icons/ --icon heroicons:heart --name Heart
npm install -g iconmate
# or
pnpm add -g iconmate
# or
bun add -g iconmate
For one-off usage:
npx iconmate
# or
pnpm dlx iconmate
# or
bunx iconmate
[!NOTE] Note for Bun users: Bun doesn't run
postinstall
scripts by default which is needed to install the iconmate binary. Add"trustedDependencies": ["iconmate"]
to yourpackage.json
to do it! But you're only limited to running it with a package.json.Recommended: Just use pnpx for quick one-off usage. If in a project, either install globally or configure trustDependencies.
cargo install iconmate
Or clone and install from source:
git clone https://github.com/blankeos/iconmate.git
cd iconmate
cargo install --path .
Determines the output filetype and the contents inside that file type.
Preset | File Type | Framework |
---|---|---|
normal |
.svg |
Vanilla HTML/CSS |
react |
.tsx |
React Components |
svelte |
.svelte |
Svelte Components |
solid |
.tsx |
Solid Components |
vue |
.vue |
Vue Components |
emptysvg |
.svg |
Placeholder |
[!IMPORTANT] If you want to use
.svg
file types, make sure to setup svgr. I covered how to do this in:
- SolidJS (Vite)
- React (Vite)
- React (NextJS)
- Vue - contribution welcome!
- Svelte - couldn't find an svgr integration :(
iconmate
# Description of each prompt:
> ๐ Folder (src/assets/icons/) # where your icons will be saved.
> โจ Preset # i.e. How will it be saved? An `.svg` or `.tsx` file in react, solid, etc.
> ๐ Icon # Source of your icon. i.e. 'heroicons:heart' from https://icones.js.org, full URL, or any SVG. Can be empty except for 'emptysvg' preset.
> ๐ Filename # The filename without the extension. i.e. heroicons:heart. Will only be prompted if you used an SVG, or an URL on icon.
> ๐ Name # The "Heart" in <IconHeart />
iconmate add --folder src/assets/icons --icon heroicons:heart --name Heart
iconmate add --folder src/assets/icons --icon https://api.iconify.design/mdi:heart.svg --name Heart
iconmate add --folder src/assets/icons --icon '<svg>...</svg>' --name Heart
iconmate add --folder src/assets/icons --icon heroicons:heart --name Heart --output-line-template "export { ReactComponent as Icon%name% } from './%icon%.svg?react';"
iconmate delete --folder src/assets/icons
Best practice: Add sensible defaults to your script runner.
"scripts": {
// Usage: npm run iconmate (usually this is the only command you need)!
"iconmate": "iconmate --folder src/assets/icons/"
// Usage: npm run iconmate-react
"iconmate-react": "iconmate --folder ./src/assets/icons/ --preset react",
// Usage: npm run iconmate-empty
"iconmate-empty": "iconmate --folder ./src/assets/icons/ --preset emptysvg",
}
heroicons:heart
.iconmate
index.ts
exports automatically and just typing <Icon
will autosuggest from your current collection. Just regular TS behavior.Contributions are welcomeโpull requests for bug fixes, new framework presets, or improvements are appreciated.
๐ฑ Repo: github.com/Blankeos/iconmate - Star it if you love it โญ
name
.--preset=svg,react,solid,svelte,vue
- which basically overrides templates. Default is svg
.iconmate
- Interactive mode so you won't need to pass arguments.iconmate delete
Made with Rust ๐ฆ | Based on my blog post