Expand description
§gpui-phosphor
gpui-phosphor is an unofficial community integration of the official
Phosphor Icons SVG assets with
GPUI. It embeds Phosphor Core 2.1.1, generates a typed
IconName enum from the SVG catalog, and renders icons with GPUI’s svg()
element.
It is not affiliated with or endorsed by Phosphor Icons.
Copyright (c) 2025-2026 eltrach. The Rust crate
is open source under MIT OR Apache-2.0. Phosphor’s original MIT license and
attribution remain preserved in LICENSE-PHOSPHOR.
§Usage
Enable the asset source when constructing the GPUI application:
use gpui::{App, Application};
use gpui_phosphor::{Icon, IconName, PhosphorAssets, Weight};
fn main() {
Application::new()
.with_assets(PhosphorAssets)
.run(|_cx: &mut App| {
let _heart = Icon::new(IconName::Heart)
.weight(Weight::Regular)
.size(gpui::px(24.0))
.color(gpui::rgb(0xe25555));
// Add `_heart` to a GPUI element tree in a real view.
});
}The component defaults to the first enabled weight, a 16px size, and the current GPUI text color:
use gpui::{div, prelude::*};
use gpui_phosphor::{Icon, IconName};
let toolbar = div()
.flex()
.gap_2()
.child(Icon::new(IconName::Heart))
.child(Icon::new(IconName::Star).size(gpui::px(20.0)));Use try_new or try_with_weight when a disabled weight should be handled as
a Rust error:
use gpui_phosphor::{Icon, IconName, Weight};
let duotone_heart = Icon::try_new(IconName::Heart, Weight::Duotone);IconName::path returns namespaced paths such as
phosphor/regular/heart.svg. The generated enum covers the complete catalog;
there is no hand-maintained icon list.
§Combining asset sources
PhosphorAssets::with_fallback composes Phosphor with an existing application
asset source:
use gpui::{Application, AssetSource, Result, SharedString};
use gpui_phosphor::PhosphorAssets;
use std::borrow::Cow;
struct ExistingAssets;
impl AssetSource for ExistingAssets {
fn load(&self, _path: &str) -> Result<Option<Cow<'static, [u8]>>> {
Ok(None) // delegate to the application’s real asset lookup here
}
fn list(&self, _path: &str) -> Result<Vec<SharedString>> {
Ok(Vec::new())
}
}
let application = Application::new()
.with_assets(PhosphorAssets::with_fallback(ExistingAssets));Phosphor assets are served first; all other paths are delegated to the
fallback source. PhosphorAssets by itself serves only Phosphor paths.
§Cargo features
Only regular is enabled by default. Each other weight is opt-in so the
compiled binary embeds only the styles an application uses:
[dependencies]
gpui-phosphor = { version = "0.1", features = ["regular", "fill", "duotone"] }Available features are regular, thin, light, bold, fill, and
duotone. Weight::is_enabled and IconName::path expose the selected build
configuration, and a disabled weight produces an actionable IconError.
§Licensing and attribution
The Rust crate is licensed under MIT OR Apache-2.0. The embedded Phosphor
SVG assets remain under the original Phosphor MIT license; see
LICENSE-PHOSPHOR and
THIRD_PARTY_NOTICES.md.
Structs§
- Icon
- A GPUI component that renders a typed Phosphor icon through GPUI’s
svg()element. - Phosphor
Asset Source - A composable source that serves Phosphor first and delegates every other asset request to an application-provided source.
- Phosphor
Assets - An
AssetSourcecontaining the enabled Phosphor SVG weights.
Enums§
- Icon
Error - Errors returned when an icon cannot be made available by the selected Cargo features.
- Icon
Name - A typed name from the Phosphor icon catalog.
- Weight
- A visual weight from the Phosphor icon family.
Constants§
- PHOSPHOR_
VERSION - The upstream Phosphor Core asset release embedded by this crate.