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
Installation
Add this to your Cargo.toml:
[]
= "*"
Quick Start
use ;
// Setup fonts (call once during initialization)
// Use icons in your UI
Feature Flags
By default, all font styles are included. You can disable specific styles to reduce binary size:
# Only include regular and bold styles
= { = "*", = false, = ["bold"] }
# Only regular style (smallest binary size)
= { = "*", = false }
# Custom selection
= { = "*", = false, = ["bold", "fill"] }
Available features:
bold- Bold font variantfill- Fill font variantlight- Light font variantthin- Thin font variant
Available Icons
This library includes all icons from Phosphor Icons. Some examples:
- UI Elements:
HOUSE,GEAR,USER,BELL,HEART,STAR - Actions:
PLAY,PAUSE,STOP,TRASH,PENCIL,CHECK - Navigation:
ARROW_LEFT,ARROW_RIGHT,CARET_DOWN,X - Communication:
CHAT,PHONE,ENVELOPE,PAPER_PLANE - Media:
IMAGE,VIDEO_CAMERA,MUSIC_NOTE,FILE - And many more...
See the full list of available icons at phosphoricons.com or in the icons module documentation.
API Reference
add_fonts(fonts: &mut egui::FontDefinitions)
Adds Phosphor Icons fonts to your egui font definitions. Call this once during initialization before setting fonts on your context.
Icon
A type representing a Phosphor icon. All icons in the icons module are of this type.
Methods
.regular()->RichText- Renders with regular style.bold()->RichText- Renders with bold style (requiresboldfeature).fill()->RichText- Renders with fill style (requiresfillfeature).light()->RichText- Renders with light style (requireslightfeature).thin()->RichText- Renders with thin style (requiresthinfeature)Icon::from_name(name: &str)->Option<Icon>- Looks up an icon by string nameIcon::names()->Iterator<&'static str>- Returns an iterator over all icon names
Icons automatically convert to RichText and WidgetText with regular style via Into, so you can use them directly:
ui.label; // Direct usage (uses regular style)
ui.label; // Explicit (equivalent)
String Lookup
You can look up icons by their string names (kebab-case), which is useful for serialization or configuration files:
// Look up by name (kebab-case)
if let Some = from_name
// Get all available icon names
for name in names
Usage with bevy_egui
When using this library with bevy_egui, you need to configure the fonts during initialization. Here's a complete example:
use *;
use ;
use ;
// Configure fonts once when the EguiContext is first added
// Now you can use icons in any UI system
Key points for bevy_egui integration:
- Add the font configuration in a system that runs on
Added<PrimaryEguiContext>to ensure it only runs once - Query for
&mut EguiContextand callctx.get_mut()to access the egui context - Icons can then be used normally in any system that has access to the egui context
Examples
Basic Icon Display
ui.label;
Styled Icons
ui.label;
ui.label;
ui.label;
Icon Buttons
if ui.button.clicked
if ui.button.clicked
Icon with Text
ui.horizontal;
Different Styles
ui.horizontal;
License
This library packages the Phosphor Icons font files. Phosphor Icons are licensed under the MIT License. See the Phosphor Icons repository for details.