pub struct ThemeVariant {Show 29 fields
pub defaults: ThemeDefaults,
pub text_scale: TextScale,
pub window: WindowTheme,
pub button: ButtonTheme,
pub input: InputTheme,
pub checkbox: CheckboxTheme,
pub menu: MenuTheme,
pub tooltip: TooltipTheme,
pub scrollbar: ScrollbarTheme,
pub slider: SliderTheme,
pub progress_bar: ProgressBarTheme,
pub tab: TabTheme,
pub sidebar: SidebarTheme,
pub toolbar: ToolbarTheme,
pub status_bar: StatusBarTheme,
pub list: ListTheme,
pub popover: PopoverTheme,
pub splitter: SplitterTheme,
pub separator: SeparatorTheme,
pub switch: SwitchTheme,
pub dialog: DialogTheme,
pub spinner: SpinnerTheme,
pub combo_box: ComboBoxTheme,
pub segmented_control: SegmentedControlTheme,
pub card: CardTheme,
pub expander: ExpanderTheme,
pub link: LinkTheme,
pub icon_set: Option<String>,
pub icon_theme: Option<String>,
}Expand description
A single light or dark theme variant containing all visual properties.
Composes defaults, per-widget structs, and optional text scale into one coherent set. Empty sub-structs are omitted from serialization to keep TOML files clean.
§Examples
use native_theme::{ThemeVariant, Rgba};
let mut variant = ThemeVariant::default();
variant.defaults.accent = Some(Rgba::rgb(0, 120, 215));
variant.defaults.font.family = Some("Inter".into());
assert!(!variant.is_empty());Fields§
§defaults: ThemeDefaultsGlobal defaults inherited by all widgets.
text_scale: TextScalePer-role text scale overrides.
window: WindowThemeWindow chrome: background, title bar, radius, shadow.
Push button: colors, sizing, spacing, geometry.
input: InputThemeSingle-line and multi-line text input fields.
checkbox: CheckboxThemeCheckbox and radio button indicator geometry.
Popup and context menu appearance.
tooltip: TooltipThemeTooltip popup appearance.
scrollbar: ScrollbarThemeScrollbar colors and geometry.
slider: SliderThemeSlider control colors and geometry.
progress_bar: ProgressBarThemeProgress bar colors and geometry.
tab: TabThemeTab bar colors and sizing.
Sidebar panel background and foreground colors.
toolbar: ToolbarThemeToolbar sizing, spacing, and font.
status_bar: StatusBarThemeStatus bar font.
list: ListThemeList and table colors and row geometry.
popover: PopoverThemePopover / dropdown panel appearance.
splitter: SplitterThemeSplitter handle width.
separator: SeparatorThemeSeparator line color.
switch: SwitchThemeToggle switch track, thumb, and geometry.
dialog: DialogThemeDialog sizing, spacing, button order, and title font.
spinner: SpinnerThemeSpinner / indeterminate progress indicator.
combo_box: ComboBoxThemeComboBox / dropdown trigger sizing.
segmented_control: SegmentedControlThemeSegmented control sizing.
card: CardThemeCard / container colors and geometry.
expander: ExpanderThemeExpander / disclosure row geometry.
link: LinkThemeHyperlink colors and underline setting.
icon_set: Option<String>Icon set / naming convention for this variant (e.g., “sf-symbols”, “freedesktop”). When None, resolved at runtime via system_icon_set().
icon_theme: Option<String>Icon theme name for this variant (e.g., “breeze”, “Adwaita”, “material”).
This is the visual icon theme, distinct from the naming convention in icon_set.
When None, resolved at runtime via system_icon_theme().
Implementations§
Source§impl ThemeVariant
impl ThemeVariant
Source§impl ThemeVariant
impl ThemeVariant
Sourcepub fn resolve(&mut self)
pub fn resolve(&mut self)
Apply all ~90 inheritance rules in 4-phase order.
After calling resolve(), most Option fields that were None will be filled from defaults or related widget fields. Calling resolve() twice produces the same result (idempotent).
§Phases
- Defaults internal chains – accent derives selection, focus_ring_color; selection derives selection_inactive.
- Safety nets – platform-divergent fields get a reasonable fallback.
- Widget-from-defaults – colors, geometry, fonts, text scale entries all inherit from defaults.
- Widget-to-widget – inactive title bar fields fall back to active.
Sourcepub fn into_resolved(self) -> Result<ResolvedThemeVariant>
pub fn into_resolved(self) -> Result<ResolvedThemeVariant>
Resolve all inheritance rules and validate in one step.
This is the recommended way to convert a ThemeVariant into a
ResolvedThemeVariant. It calls resolve() followed
by validate(), ensuring no fields are left
unresolved.
§Errors
Returns crate::Error::Resolution if any fields remain None after
resolution (e.g., when accent color is missing and cannot be derived).
§Examples
use native_theme::ThemeSpec;
let theme = ThemeSpec::preset("dracula").unwrap();
let variant = theme.dark.unwrap();
let resolved = variant.into_resolved().unwrap();
// All fields are now guaranteed populated
let accent = resolved.defaults.accent;Sourcepub fn validate(&self) -> Result<ResolvedThemeVariant>
pub fn validate(&self) -> Result<ResolvedThemeVariant>
Convert this ThemeVariant into a ResolvedThemeVariant with all fields guaranteed.
Should be called after resolve(). Walks every field
and collects missing (None) field paths. Returns Ok(ResolvedThemeVariant) if all fields
are populated, or Err(Error::Resolution(...)) listing every missing field.
§Errors
Returns crate::Error::Resolution containing a ThemeResolutionError
with all missing field paths if any fields remain None.
Trait Implementations§
Source§impl Clone for ThemeVariant
impl Clone for ThemeVariant
Source§fn clone(&self) -> ThemeVariant
fn clone(&self) -> ThemeVariant
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more