Skip to main content

to_theme

Function to_theme 

Source
pub fn to_theme(resolved: &ResolvedThemeVariant, name: &str) -> Theme
Expand description

Create an iced iced_core::theme::Theme from a native_theme::ResolvedThemeVariant.

Builds a custom theme using Theme::custom_with_fn(), which:

  1. Maps the 6 Palette fields from resolved theme colors via palette::to_palette()
  2. Generates an Extended palette, then overrides secondary and background.weak entries via extended::apply_overrides()

The resulting theme carries the mapped Palette and Extended palette. iced’s built-in Catalog trait implementations for all 8 core widgets (Button, Container, TextInput, Scrollable, Checkbox, Slider, ProgressBar, Tooltip) automatically derive their Style structs from this palette. No explicit Catalog implementations are needed.

The name sets the theme’s display name (visible in theme pickers). For the common case, use from_preset() to derive the name automatically.