# native-theme-gpui
[gpui](https://gpui.rs/) + [gpui-component](https://crates.io/crates/gpui-component)
toolkit connector for [native-theme](https://crates.io/crates/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`:
```toml
[dependencies]
native-theme = "0.4"
native-theme-gpui = "0.4"
```
Then create a gpui-component theme from any native-theme preset or OS theme:
```rust
use native_theme::NativeTheme;
use native_theme_gpui::{pick_variant, to_theme};
// Load a preset
let nt = NativeTheme::preset("dracula").unwrap();
// Pick light or dark variant (with cross-fallback)
let is_dark = true;
if let Some(variant) = pick_variant(&nt, is_dark) {
let theme = to_theme(variant, "My App", is_dark);
// Use `theme` in your gpui-component application
}
```
Or read the OS theme at runtime:
```rust
use native_theme::{from_system, NativeTheme};
use native_theme_gpui::{pick_variant, to_theme};
call it on every frame tick.
## Modules
| `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, image source conversion, and animated icon playback |
## Example
Run the showcase widget gallery to explore all 17 presets interactively:
```sh
cargo run -p native-theme-gpui --example showcase
```
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.
Generate screenshots (requires a display server):
```sh
bash scripts/generate_screenshots.sh
```
## License
Licensed under either of
- [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
- [MIT License](http://opensource.org/licenses/MIT)
- [0BSD License](https://opensource.org/license/0bsd)
at your option.