License-aware icon packs for GPUI
翻译准备中
正在加载完整 README。
查看完整 README ↗The complete Lucide icon set for GPUI: 1,924 canonical icons and 269 aliases from Lucide 1.63.0. Every icon uses the original upstream SVG, embedded in your application. Native and WASM use the same assets without fetching anything at runtime.
This is a standalone icon library. You can use it with any GPUI application; gpuicn is one consumer. It is not affiliated with Lucide.
cargo add gpui-icons
Or add it to Cargo.toml yourself:
[dependencies]
gpui-icons = "0.7.0"
It needs Rust 1.98 or newer and the GPUI runtime described in Reproducible source.
Register the asset source before rendering icons:
use gpui::{Styled, px, rgb};
use gpui_icons::{LucideAssetSource, LucideIcon, lucide};
// On your Application builder:
// application.with_assets(LucideAssetSource).run(...);
let search = lucide(LucideIcon::Search).size(px(16.)).text_color(rgb(0x171717));
let folder = LucideIcon::Folder.element().size(px(24.)).text_color(rgb(0x171717));
let icon = LucideIcon::from_name("alarm-clock").unwrap();
let parsed: LucideIcon = "trash-2".parse()?; // aliases work too
assert_eq!(LucideIcon::AlarmClock.to_string(), "alarm-clock");
Set .text_color(...) explicitly from your theme: GPUI does not paint an
SVG without it. Size icons at 16, 20, 24, or 32 pixels as appropriate. Give icon-only
buttons an accessible label on the button; a decorative SVG is not a control.
LucideIcon::ALL contains the full canonical set in name order. from_name
accepts canonical kebab-case names and upstream aliases, including deprecated
names such as align-center. Unknown names return None; FromStr and
TryFrom<&str> return an UnknownIcon error instead, and Display writes the
canonical name, so icon names round-trip through config files and settings.
LucideAssetSource owns icons/lucide/. It returns Ok(None) for unrelated
paths and an explicit error for an unknown Lucide icon. Delegate only when it
returns None:
use std::borrow::Cow;
use gpui::{AssetSource, Result, SharedString};
use gpui_icons::LucideAssetSource;
struct AppAssets<S> {
application: S,
}
impl<S: AssetSource> AssetSource for AppAssets<S> {
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
match LucideAssetSource.load(path)? {
Some(asset) => Ok(Some(asset)),
None => self.application.load(path),
}
}
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
match path {
"icons/lucide" | "icons/lucide/" => LucideAssetSource.list(path),
_ => self.application.list(path),
}
}
}
GPUI is pinned to gpui-pre = 0.3.12, matching GPUI Kit 0.9.1. Applications can
use gpui-kit = "=0.9.1" or gpui = { package = "gpui-pre", version = "=0.3.12" }.
Do not mix these types with a separate Zed Git dependency.
GPUI Kit now includes its own Lucide catalog. Use its assets for applications
that only need named icons. This crate retains canonical and alias lookup,
search metadata, exact upstream hashes, and a complete embedded asset source
on both native and WASM. LucideIcon::Trash2 remains an alias for Trash.
Icons that Lucide renamed after 1.43.0, such as LucideIcon::Music, remain
constants for their new names.
The release manifest records canonical names, aliases,
tags, categories, contributors, and hashes for every upstream SVG and metadata
file. Schema 4 drops upstream.archive_sha256: the generator now verifies the
pinned commit with git instead of hashing a GitHub tarball. Assets come from Lucide 1.63.0.
To regenerate, run python3 scripts/generate.py. The script fetches the
pinned upstream commit with git, checks its hash, and reads it with
git archive. You can also pass a local tar archive of that commit as its
first argument. Python, git and rustfmt are the only generation tools; consumers do not run a build script.
Run cargo test --lib to check every icon's lookup, asset path, bytes, metadata
hash, aliases, and license against the pinned release. Run cargo fmt --check
and cargo clippy --lib --tests -- -D warnings before a release.
Merging a version bump to main is the release. Bump version in
Cargo.toml and RELEASE-MANIFEST.json together. When CI passes on main,
the Release workflow tags the commit v<version>, publishes the crate to
crates.io with Trusted Publishing (environment release) and publishes the
GitHub release. A merge that doesn't change the version releases nothing.
Release gpui-icons before a gpuicn release that needs the new version.
The Rust code is MIT-licensed in LICENSES/gpui-icons-MIT.
The exact upstream LICENSE covers Lucide's ISC and Feather-derived
MIT terms. Package metadata declares MIT AND ISC.