Skip to main content

ThemeDefaults

Struct ThemeDefaults 

Source
pub struct ThemeDefaults {
Show 39 fields pub font: FontSpec, pub line_height: Option<f32>, pub mono_font: FontSpec, pub background: Option<Rgba>, pub foreground: Option<Rgba>, pub accent: Option<Rgba>, pub accent_foreground: Option<Rgba>, pub surface: Option<Rgba>, pub border: Option<Rgba>, pub muted: Option<Rgba>, pub shadow: Option<Rgba>, pub link: Option<Rgba>, pub selection: Option<Rgba>, pub selection_foreground: Option<Rgba>, pub selection_inactive: Option<Rgba>, pub disabled_foreground: Option<Rgba>, pub danger: Option<Rgba>, pub danger_foreground: Option<Rgba>, pub warning: Option<Rgba>, pub warning_foreground: Option<Rgba>, pub success: Option<Rgba>, pub success_foreground: Option<Rgba>, pub info: Option<Rgba>, pub info_foreground: Option<Rgba>, pub radius: Option<f32>, pub radius_lg: Option<f32>, pub frame_width: Option<f32>, pub disabled_opacity: Option<f32>, pub border_opacity: Option<f32>, pub shadow_enabled: Option<bool>, pub focus_ring_color: Option<Rgba>, pub focus_ring_width: Option<f32>, pub focus_ring_offset: Option<f32>, pub spacing: ThemeSpacing, pub icon_sizes: IconSizes, pub text_scaling_factor: Option<f32>, pub reduce_motion: Option<bool>, pub high_contrast: Option<bool>, pub reduce_transparency: Option<bool>,
}
Expand description

Global theme defaults shared across all widgets.

§Field structure

This struct uses two patterns for its fields:

  • Option<T> leaf fields (accent, radius, line_height, etc.) — None means “not set.” During merge, an overlay’s Some value replaces the base wholesale.

  • Non-Option nested struct fields (font, mono_font, spacing, icon_sizes) — these support partial field-by-field override during merge. For example, an overlay that sets only font.size will inherit the base’s font.family and font.weight. This makes theme merging more flexible: you can fine-tune individual properties without replacing the entire sub-struct.

This asymmetry is intentional. Checking “is accent set?” is defaults.accent.is_some(), while checking “is font set?” requires inspecting individual fields like defaults.font.family.is_some().

When resolving a widget’s properties, None on the widget struct means “inherit from ThemeDefaults”.

Fields§

§font: FontSpec

Primary UI font (family, size, weight).

§line_height: Option<f32>

Line height multiplier (e.g. 1.4 = 140% of font size).

§mono_font: FontSpec

Monospace font for code/terminal content.

§background: Option<Rgba>

Main window/surface background color.

§foreground: Option<Rgba>

Default text color.

§accent: Option<Rgba>

Accent/brand color for interactive elements.

§accent_foreground: Option<Rgba>

Text color used on accent-colored backgrounds.

§surface: Option<Rgba>

Elevated surface color (cards, dialogs, popovers).

§border: Option<Rgba>

Border/divider color.

§muted: Option<Rgba>

Secondary/subdued text color.

§shadow: Option<Rgba>

Drop shadow color (with alpha).

§link: Option<Rgba>

Hyperlink text color.

§selection: Option<Rgba>

Selection highlight background.

§selection_foreground: Option<Rgba>

Text color over selection highlight.

§selection_inactive: Option<Rgba>

Selection background when window is unfocused.

§disabled_foreground: Option<Rgba>

Text color for disabled controls.

§danger: Option<Rgba>

Danger/error color.

§danger_foreground: Option<Rgba>

Text color on danger-colored backgrounds.

§warning: Option<Rgba>

Warning color.

§warning_foreground: Option<Rgba>

Text color on warning-colored backgrounds.

§success: Option<Rgba>

Success/confirmation color.

§success_foreground: Option<Rgba>

Text color on success-colored backgrounds.

§info: Option<Rgba>

Informational color.

§info_foreground: Option<Rgba>

Text color on info-colored backgrounds.

§radius: Option<f32>

Default corner radius in logical pixels.

§radius_lg: Option<f32>

Large corner radius (dialogs, floating panels).

§frame_width: Option<f32>

Border/frame width in logical pixels.

§disabled_opacity: Option<f32>

Opacity for disabled controls (0.0–1.0).

§border_opacity: Option<f32>

Border alpha multiplier (0.0–1.0).

§shadow_enabled: Option<bool>

Whether drop shadows are enabled.

§focus_ring_color: Option<Rgba>

Focus indicator outline color.

§focus_ring_width: Option<f32>

Focus indicator outline width.

§focus_ring_offset: Option<f32>

Gap between element edge and focus indicator.

§spacing: ThemeSpacing

Logical spacing scale (xxs through xxl).

§icon_sizes: IconSizes

Per-context icon sizes.

§text_scaling_factor: Option<f32>

Text scaling factor (1.0 = no scaling).

§reduce_motion: Option<bool>

Whether the user has requested reduced motion.

§high_contrast: Option<bool>

Whether a high-contrast mode is active.

§reduce_transparency: Option<bool>

Whether the user has requested reduced transparency.

Implementations§

Source§

impl ThemeDefaults

Source

pub const FIELD_NAMES: &[&str]

All serialized field names for ThemeDefaults, for TOML linting.

Source§

impl ThemeDefaults

Source

pub fn merge(&mut self, overlay: &Self)

Merge an overlay into this value. Some fields in the overlay replace the corresponding fields in self; None fields are left unchanged. Nested structs are merged recursively.

Source

pub fn is_empty(&self) -> bool

Returns true if all fields are at their default (None/empty) state.

Trait Implementations§

Source§

impl Clone for ThemeDefaults

Source§

fn clone(&self) -> ThemeDefaults

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThemeDefaults

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ThemeDefaults

Source§

fn default() -> ThemeDefaults

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ThemeDefaults

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ThemeDefaults

Source§

fn eq(&self, other: &ThemeDefaults) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ThemeDefaults

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ThemeDefaults

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,