dioxus-iconify
CLI tool for generating Iconify icons 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
- π¦ 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
Usage
- Add icons to your project:
# Add single icon
# Add multiple icons
# Specify custom output directory
- Use in your Dioxus components:
use *;
use Icon;
use mdi;
π 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 = GlobalAttributes 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:
# Examples
init
Initialize the icons directory (creates mod.rs):
Coming Soon
remove- Remove icons from your projectlist- List all generated iconsupdate- Re-fetch and update all icons
π Comparison with Other Solutions
| Feature | dioxus-iconify | Embedded Libraries | SVG Files |
|---|---|---|---|
| Icon Count | 275,000+ | Limited | Manual |
| Dependency Size | 0 (CLI only) | Large | 0 |
| Type Safety | β | β | β |
| Customization | Full | Limited | Full |
| Fix issue | 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
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
π Acknowledgments
- Iconify - For providing the amazing icon API and collections
- shadcn-ui - For inspiration on the CLI-based generation approach
- iconmate - For similar ideas in the TypeScript ecosystem
- Dioxus - The amazing Rust UI framework