Skip to main content

Crate native_theme_iced

Crate native_theme_iced 

Source
Expand description

iced toolkit connector for native-theme.

Maps native_theme::ResolvedThemeVariant data to iced’s theming system.

§Quick Start

use native_theme_iced::from_preset;

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

Or from the OS-detected theme:

use native_theme_iced::from_system;

let theme = from_system()?;

§Manual Path

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

use native_theme::ThemeSpec;
use native_theme_iced::to_theme;

let nt = ThemeSpec::preset("catppuccin-mocha").unwrap();
let mut variant = nt.pick_variant(false).unwrap().clone();
variant.resolve();
let resolved = variant.validate().unwrap();
let theme = to_theme(&resolved, "My App");

§Theme Field Coverage

The connector maps a subset of ResolvedThemeVariant to iced’s theming system:

TargetFieldsSource
Palette (6 fields)background, text, primary, success, warning, dangerdefaults.*
Extended overrides (4)secondary.base.color/text, background.weak.color/textbutton.bg/fg, defaults.surface/foreground
Widget metricsbutton/input padding, border radius, scrollbar widthPer-widget resolved fields
Typographyfont family/size/weight, mono family/size/weight, line heightdefaults.font.*, defaults.mono_font.*

Per-widget geometry beyond padding/radius (e.g., min-width, disabled-opacity) is not mapped because iced applies these via inline widget configuration, not through the theme system. Users can read these directly from the ResolvedThemeVariant they pass to to_theme().

Modules§

extended
Extended palette overrides from native_theme::ResolvedThemeVariant fields.
icons
Icon conversion helpers for iced.
palette
Maps native_theme::ResolvedThemeVariant colors to an iced_core::theme::Palette.

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

Traits§

IconProvider
Trait for types that map icon identifiers to platform-specific names and SVG data.
SystemThemeExt
Extension trait for converting a SystemTheme to an iced theme.

Functions§

border_radius
Returns the standard border radius from the resolved theme.
border_radius_lg
Returns the large border radius from the resolved theme.
button_padding
Returns button padding from the resolved theme as an iced Padding.
font_family
Returns the primary UI font family name from the resolved theme.
font_size
Returns the primary UI font size in logical pixels from the resolved theme.
font_weight
Returns the primary UI font weight (CSS 100-900) from the resolved theme.
from_preset
Load a bundled preset and convert it to an iced Theme in one call.
from_system
Detect the OS theme and convert it to an iced Theme in one call.
input_padding
Returns text input padding from the resolved theme as an iced Padding.
line_height
Returns the primary UI line height in logical pixels from the resolved theme.
mono_font_family
Returns the monospace font family name from the resolved theme.
mono_font_size
Returns the monospace font size in logical pixels from the resolved theme.
mono_font_weight
Returns the monospace font weight (CSS 100-900) from the resolved theme.
scrollbar_width
Returns the scrollbar width from the resolved theme.
to_theme
Create an iced iced_core::theme::Theme from a native_theme::ResolvedThemeVariant.