Expand description
§egui_phosphor_icons
A Rust library providing Phosphor Icons for egui.
§Features
- Multiple font styles: Regular, Bold, Fill, Light, and Thin variants
- Feature flags: Control which font styles are included to reduce binary size
- String lookup: Look up icons by name for serialization/configuration support
§Quick Start
use egui_phosphor_icons::{add_fonts, icons, Icon};
// Setup fonts (call once during initialization)
let mut fonts = egui::FontDefinitions::default();
add_fonts(&mut fonts);
ctx.set_fonts(fonts);
// Use icons in your UI
ui.label(icons::HOUSE); // Regular style (default)
ui.label(icons::HOUSE.bold()); // Bold style
ui.label(icons::HOUSE.fill()); // Fill style
ui.label(icons::HOUSE.light()); // Light style
ui.label(icons::HOUSE.thin()); // Thin style
// Chain with RichText methods
ui.label(icons::HEART.fill().color(egui::Color32::RED).size(32.0));
// Look up icons by string name (kebab-case)
if let Some(icon) = Icon::from_name("arrow-up-left") {
ui.label(icon.regular());
}§Feature Flags
By default, all font styles are included. You can disable specific styles to reduce binary size:
# Only include regular and bold styles
egui_phosphor_icons = { version = "0.1.0", default-features = false, features = ["bold"] }
# Only regular style (smallest binary size)
egui_phosphor_icons = { version = "0.1.0", default-features = false }Available features:
bold- Bold font variantfill- Fill font variantlight- Light font variantthin- Thin font variant
§Usage with bevy_egui
When using this library with bevy_egui, configure fonts during initialization:
ⓘ
use bevy::prelude::*;
use bevy_egui::{EguiContext, EguiPlugin, PrimaryEguiContext, egui};
use egui_phosphor_icons::{add_fonts, icons};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(EguiPlugin)
.add_systems(Update, configure_fonts)
.run();
}
// Configure fonts once when EguiContext is first added
fn configure_fonts(mut egui_contexts: Query<&mut EguiContext, Added<PrimaryEguiContext>>) {
let Some(mut ctx) = egui_contexts.iter_mut().next() else {
return;
};
let mut fonts = egui::FontDefinitions::default();
add_fonts(&mut fonts);
ctx.get_mut().set_fonts(fonts);
}Modules§
Structs§
- Icon
- A Phosphor icon that can be rendered with different font styles.
Functions§
- add_
fonts - Adds Phosphor Icons font to egui font definitions.