gpui-phosphor 0.1.0

An unofficial GPUI component and asset source for Phosphor Icons
Documentation
  • Coverage
  • 100%
    1527 out of 1527 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.0 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 22s Average build duration of successful builds.
  • all releases: 1m 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • eltrach/gpui-phosphor
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eltrach

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.