Skip to main content

ThemeDefaults

Struct ThemeDefaults 

Source
pub struct ThemeDefaults {
Show 36 fields pub font: FontSpec, pub line_height: Option<f32>, pub mono_font: FontSpec, pub background_color: Option<Rgba>, pub text_color: Option<Rgba>, pub accent_color: Option<Rgba>, pub accent_text_color: Option<Rgba>, pub surface_color: Option<Rgba>, pub muted_color: Option<Rgba>, pub shadow_color: Option<Rgba>, pub link_color: Option<Rgba>, pub selection_background: Option<Rgba>, pub selection_text_color: Option<Rgba>, pub selection_inactive_background: Option<Rgba>, pub text_selection_background: Option<Rgba>, pub text_selection_color: Option<Rgba>, pub disabled_text_color: Option<Rgba>, pub danger_color: Option<Rgba>, pub danger_text_color: Option<Rgba>, pub warning_color: Option<Rgba>, pub warning_text_color: Option<Rgba>, pub success_color: Option<Rgba>, pub success_text_color: Option<Rgba>, pub info_color: Option<Rgba>, pub info_text_color: Option<Rgba>, pub border: BorderSpec, pub disabled_opacity: Option<f32>, pub focus_ring_color: Option<Rgba>, pub focus_ring_width: Option<f32>, pub focus_ring_offset: Option<f32>, pub icon_sizes: IconSizes, pub font_dpi: Option<f32>, 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_color, disabled_opacity, 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, border, 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_color set?” is defaults.accent_color.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_color: Option<Rgba>

Main window/surface background color.

§text_color: Option<Rgba>

Default text color.

§accent_color: Option<Rgba>

Accent/brand color for interactive elements.

§accent_text_color: Option<Rgba>

Text color used on accent-colored backgrounds.

§surface_color: Option<Rgba>

Elevated surface color (cards, dialogs, popovers).

§muted_color: Option<Rgba>

Secondary/subdued text color.

§shadow_color: Option<Rgba>

Drop shadow color (with alpha).

§link_color: Option<Rgba>

Hyperlink text color.

§selection_background: Option<Rgba>

Selection highlight background.

§selection_text_color: Option<Rgba>

Text color over selection highlight.

§selection_inactive_background: Option<Rgba>

Selection background when window is unfocused.

§text_selection_background: Option<Rgba>

Text selection background (inline text highlight).

§text_selection_color: Option<Rgba>

Text selection color (inline text highlight).

§disabled_text_color: Option<Rgba>

Text color for disabled controls.

§danger_color: Option<Rgba>

Danger/error color.

§danger_text_color: Option<Rgba>

Text color on danger-colored backgrounds.

§warning_color: Option<Rgba>

Warning color.

§warning_text_color: Option<Rgba>

Text color on warning-colored backgrounds.

§success_color: Option<Rgba>

Success/confirmation color.

§success_text_color: Option<Rgba>

Text color on success-colored backgrounds.

§info_color: Option<Rgba>

Informational color.

§info_text_color: Option<Rgba>

Text color on info-colored backgrounds.

§border: BorderSpec

Border sub-struct (color, corner_radius, line_width, etc.).

§disabled_opacity: Option<f32>

Opacity for disabled controls (0.0–1.0).

§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.

§icon_sizes: IconSizes

Per-context icon sizes.

§font_dpi: Option<f32>

Font DPI for pt-to-px conversion. When Some(dpi), font sizes in this variant are in typographic points and will be converted during resolution: px = pt * font_dpi / 72. When None, into_resolved() auto-detects the DPI from the OS.

This is a runtime value — not stored in TOML presets. OS readers auto-detect it from system settings. Applications can override it via the Rust API (e.g. when a window moves between monitors with different DPIs).

§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>,