# gpui-phosphor
`gpui-phosphor` is an unofficial community integration of the official
[Phosphor Icons](https://phosphoricons.com/) SVG assets with
[GPUI](https://gpui.rs/). 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](https://github.com/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`](LICENSE-PHOSPHOR).
## Usage
Enable the asset source when constructing the GPUI application:
```rust,no_run
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:
```rust
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:
```rust
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:
```rust
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:
```toml
[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`](LICENSE-PHOSPHOR) and
[`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).