dioxus-iconify
CLI tool for importing/vendoring icons from Iconify (material, lucid, heroicons,....) or from local SVG files in Dioxus projects.
Use any of the 275,000+ icons from Iconify in your Dioxus applications with a simple CLI tool. Icons are generated at build time as Rust source code, eliminating runtime dependencies.
β¨ Features
- π¨ 275k+ Icons: Access icons from Material Design, Heroicons, FontAwesome, Lucide, and 200+ other icon sets
- π Local SVG Support: Import your own SVG files or entire directories
- π¦ Type-Safe: Generated as Rust const values, checked at compile time
- π¦ Zero Runtime Dependencies: No need to depend on this crate at compile time and runtime - only Dioxus
- ποΈ Well Organized: Icons grouped by collection in separate files
- π― Fully Customizable: Override any SVG attribute (size, color, stroke, etc.)
- πΎ Git-Friendly: Generated code is committed to your repository
- β‘ CLI-Based: Simple
addcommand inspired by shadcn-ui and dioxus components
π Quick Start
Installation
# via cargo-binstall
# brew (mac & linux)
# via mise (cli or configuration file)
# curl + bash script
|
Usage
-
Choose your icons on Iconify - home of open source icons
-
Add icons to your project:
# Add icons from Iconify
# Add multiple icons
# Add local SVG file
# Add all SVGs from a directory (recursively)
# Mix Iconify and local icons
# Skip icons that already exist (don't overwrite)
# Specify custom output directory
- Use in your Dioxus Element:
use crate;
use *;
Create a module to alias other icons/app.rs
// My application iconset
// - aliasing icon from other iconset to not expose other iconset outside
pub use ArrowLeft;
pub use Home as House;
Only pub this module in icons/mod.rs (to redo after each dioxus-iconify update)
// ...
Use icons data from icons::app::*;
use crate;
use *;
π How It Works
The Problem
Existing Dioxus icon libraries typically bundle all icons in the crate, leading to:
- Large dependency sizes
- Slower compile times
- Including icons you don't use
The Solution
dioxus-iconify takes inspiration from shadcn-ui: instead of shipping icons as a dependency, it generates the icon code directly in your project.
What Gets Generated
When you run dioxus-iconify add mdi:home heroicons:arrow-left, it creates:
src/icons/
βββ mod.rs # Icon component + IconData struct + module declarations
βββ mdi.rs # Material Design Icons: Home, ...
βββ heroicons.rs # Heroicons: ArrowLeft, ...
src/icons/mod.rs:
// Auto-generated by dioxus-iconify - DO NOT EDIT
use *;
src/icons/mdi.rs:
// Auto-generated by dioxus-iconify - DO NOT EDIT
// Collection: mdi
use IconData;
pub const Home: IconData = IconData ;
π¨ Icon Customization
The Icon component uses Dioxus 0.7's extends = SvgAttributes pattern, allowing you to override any SVG attribute:
Icon
π Finding Icons
Browse available icons at:
Icon names follow the format collection:icon-name:
mdi:home- Material Design Iconsheroicons:arrow-left- Heroiconslucide:settings- Lucidefa:github- Font Awesomesimple-icons:rust- Simple Icons
π CLI Commands
add
Add icons to your project from Iconify API or local SVG files:
# Custom output directory
Local SVG Files
When adding local SVG files:
- Single files: Collection name is taken from the parent directory name
./assets/logo.svgβ collection:assets, icon:logo
- Directories: Collection name is the directory name, icons are scanned recursively
./my-icons/home.svgβmy-icons:home./my-icons/arrows/left.svgβmy-icons:arrows-left
- SVG processing: Automatically extracts dimensions from
width,height, andviewBoxattributes - Missing dimensions: Defaults to 24x24 if not specified in the SVG
init
Initialize the icons directory (creates mod.rs):
list
List all generated icons:
update
Re-fetch and update all icons from Iconify API:
Coming Soon
remove- Remove icons from your project
π Comparison with Other Solutions
| Feature | dioxus-iconify | Embedded Libraries | SVG Files |
|---|---|---|---|
| Icon Count | 275,000+ | Limited | Manual |
| Uptodate Icons | β | Depends | Manual |
| Dependency Size | 0 (CLI only) | Large | 0 |
| Type Safety | Mixed | β | β |
| Customization | Full | Limited | Full |
| Fixes/workaround | Full | Take time | Full |
| Offline Support | β (committed) | β | β |
| Updates | CLI command | Crate update | Manual |
Some Embedded libraries of icons for dioxus: dioxus-free-icons, dioxus-material-icons, dioxus-heroicons, ...
Search Results for 'dioxus icons' - crates.io: Rust Package Registry
π‘ Tips
- Commit generated code: The
src/icons/directory should be committed to version control - Customize the Icon component: It's generated in your project, so modify it if needed
- Use with Tailwind: Icon colors work with Tailwind's
text-*classes viacurrentColor - Organization: Icons are automatically grouped by collection in separate files
- Local SVGs: Use the
--skip-existingflag when adding directories to avoid overwriting customized icons - Nested directories: Icons in subdirectories are automatically named with hyphens (e.g.,
arrows/left.svgbecomesarrows-left)
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π Acknowledgments
For inspiration
- shadcn-ui - For inspiration on the CLI-based generation approach
- Dioxus Components - Like shadcn but for dioxus
- iconmate - For similar ideas in the TypeScript ecosystem