Skip to main content

Crate native_theme_gpui

Crate native_theme_gpui 

Source
Expand description

gpui toolkit connector for native-theme.

Maps native_theme::ResolvedThemeVariant data to gpui-component’s theming system.

§Quick Start

use native_theme_gpui::from_preset;

let (theme, resolved) = from_preset("catppuccin-mocha", true)?;

Or from the OS-detected theme:

use native_theme_gpui::from_system;

let (theme, resolved) = from_system()?;

§Manual Path

For full control over the resolve/validate/convert pipeline:

use native_theme::ThemeSpec;
use native_theme_gpui::to_theme;

let nt = ThemeSpec::preset("catppuccin-mocha").unwrap();
let variant = nt.into_variant(false).unwrap();
let resolved = variant.into_resolved().unwrap();
let theme = to_theme(&resolved, "Catppuccin Mocha", false);

§Theme Field Coverage

The connector maps a subset of ResolvedThemeVariant fields to gpui-component’s ThemeColor (108 color fields) and ThemeConfig (font/geometry).

CategoryMappedNotes
defaults colorsAll 20+background, foreground, accent, danger, etc.
defaults geometryradius, radius_lg, shadowFont family/size also mapped
button4 of 14primary_background/foreground, background/foreground (colors only)
tab5 of 9All colors, sizing not mapped
sidebar2 of 2background, foreground
window2 of 10title_bar_background, border
input2 of 12border, caret
scrollbar2 of 7thumb, thumb_hover
slider, switch2 eachfill/thumb colors
progress_bar1 of 5fill
list1 of 11alternate_row
popover2 of 4background, foreground
14 other widgets0 fieldscheckbox, menu, tooltip, dialog, etc.

Why the gap: gpui-component’s ThemeColor is a flat color bag with no per-widget geometry. The connector cannot map most sizing/spacing data because the target type has no corresponding fields. Users who need per-widget geometry can read it directly from the ResolvedThemeVariant they passed to to_theme().

Modules§

icons
Icon conversion functions for the gpui connector.

Structs§

ResolvedThemeVariant
A fully resolved theme where every field is guaranteed populated.
SystemTheme
Result of the OS-first pipeline. Holds both resolved variants.
ThemeSpec
A complete native theme with a name and optional light/dark variants.
ThemeVariant
A single light or dark theme variant containing all visual properties.

Enums§

AnimatedIcon
An animated icon, either frame-based or transform-based.
Error
Errors that can occur when reading or processing theme data.
IconData
Icon data returned by loading functions.
IconRole
Semantic icon roles for cross-platform icon resolution.
IconSet
Known icon sets that provide platform-specific icon identifiers.
LinuxDesktop
Desktop environments recognized on Linux.
TransformAnimation
A CSS-like transform animation applied to a single icon.

Traits§

IconProvider
Trait for types that map icon identifiers to platform-specific names and SVG data.
SystemThemeExt
Extension trait for converting a SystemTheme to a gpui-component Theme.

Functions§

from_preset
Load a bundled preset and convert it to a gpui-component Theme in one call.
from_system
Detect the OS theme and convert it to a gpui-component Theme in one call.
to_theme
Convert a ResolvedThemeVariant into a gpui-component Theme.