native-theme-gpui
gpui + gpui-component toolkit connector for native-theme.
Maps native_theme::NativeTheme data to gpui-component's theming system,
producing a fully configured Theme with correct colors, fonts, geometry,
and icons for all gpui-component widgets.
Usage
Add both crates to your Cargo.toml:
[]
= "0.3"
= "0.3"
Then create a gpui-component theme from any native-theme preset or OS theme:
use NativeTheme;
use ;
// Load a preset
let nt = preset.unwrap;
// Pick light or dark variant (with cross-fallback)
let is_dark = true;
if let Some = pick_variant
Or read the OS theme at runtime:
use ;
use ;
let nt = from_system.unwrap_or_else;
let is_dark = true;
if let Some = pick_variant
What Gets Mapped
The connector translates native-theme's 36 semantic color roles into
gpui-component's 108-field ThemeColor struct. The mapping works in layers:
- Direct mappings (~30 fields) -- background, foreground, accent, border, muted, input, ring, selection, link
- Derived fields (~78 fields) -- hover/active states, chart colors, tab bar, sidebar, scrollbar, and other widget-specific colors are generated from the base roles via shade derivation and alpha blending
Fonts and geometry (family, size, radius, shadow) are mapped to
gpui-component's ThemeConfig. Point sizes are converted to pixels (x96/72).
Icons
The connector maps native-theme's IconRole variants to gpui-component's
IconName enum, covering 30 of 42 semantic roles (actions, navigation,
status indicators, etc.).
It also provides reverse-mapping functions for loading icon assets from native-theme's icon bundles:
lucide_name_for_gpui_icon()-- maps gpui-component icon names to Lucide SVG filenamesmaterial_name_for_gpui_icon()-- maps to Material Symbols icon namesfreedesktop_name_for_gpui_icon()-- maps to FreeDesktop icon names (Linux)to_image_source()-- converts native-themeIconDatato gpuiImageSource
Custom Icons
For app-specific icons defined via native-theme-build, the connector provides:
custom_icon_to_image_source(provider, icon_set)-- load a custom icon as a gpuiImageSourcecustom_icon_to_image_source_colored(provider, icon_set, color)-- load with color tinting
These work with any type implementing IconProvider.
Modules
| Module | Purpose |
|---|---|
colors |
Maps 36 semantic colors to 108 ThemeColor fields |
config |
Maps fonts and geometry to ThemeConfig |
derive |
Hover/active state color derivation helpers |
icons |
Icon role mapping and image source conversion |
Example
Run the showcase widget gallery to explore all 17 presets interactively:
The showcase displays all gpui-component widgets (buttons, inputs, tables, charts, overlays, etc.) themed with native-theme presets, with live theme switching and a color map inspector.
License
Licensed under either of
at your option.