Expand description
Proc macro to create icon enums with embedded SVG content
This macro downloads SVG icons during compilation and embeds them in the binary. Currently supports Tabler icons from unpkg.com.
To find the name of the icon use tabler
all cached in target/icon_cache for 30 days
§Examples
Basic usage:
use tabler_icon_definer::tabler_icon;
tabler_icon!(
brand_github[outline, filled],
user[outline]
);
// Generate
// - Tabler::OUTLINE_BRAND_GITHUB
// - Tabler::FILLED_BRAND_GITHUB
// - Tabler::OUTLINE_USER
With custom name and attributes:
use tabler_icon_definer::tabler_icon;
tabler_icon!(
#[derive(serde::Serialize)]
#[name = "github"]
brand_github[outline, filled],
user[outline]
);
// Generate
// - Tabler::OUTLINE_GITHUB
// - Tabler::FILLED_GITHUB
// - Tabler::OUTLINE_USER
Using generated enum:
let icon = Tabler::OUTLINE_GITHUB;
let svg = icon.as_str(); // Get SVG content
let name = icon.as_str_merget(); // Get icon name without style prefix
let full_name = icon.to_string(); // Get icon name with style prefix
§Limitations
- first item is default item
Macros§
- tabler_
icon - Proc macro to create icon enums with embedded SVG content