Skip to main content

Crate native_theme_iced

Crate native_theme_iced 

Source
Expand description

iced toolkit connector for native-theme.

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

§Overview

This crate provides a thin mapping layer from native_theme::ThemeVariant to iced_core::theme::Theme. The main entry point is to_theme(), which produces a valid iced Theme with correct colors for all built-in widget styles via iced’s Catalog system.

Widget metrics (padding, border radius, scrollbar width) are exposed as helper functions rather than through the Catalog, since iced applies these on widget instances.

§Example

use native_theme::NativeTheme;
use native_theme_iced::to_theme;

let nt = NativeTheme::preset("default").unwrap();
if let Some(variant) = nt.pick_variant(false) {
    let theme = to_theme(variant, "My App");
    // Use `theme` as your iced application theme
}

Modules§

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

Functions§

border_radius
Returns the standard border radius from geometry, defaulting to 4.0.
border_radius_lg
Returns the large border radius from geometry, defaulting to 8.0.
button_padding
Returns button padding as [horizontal, vertical] from widget metrics.
font_family
Returns the primary UI font family name from the theme variant.
font_size
Returns the primary UI font size in pixels from the theme variant.
input_padding
Returns text input padding as [horizontal, vertical] from widget metrics.
mono_font_family
Returns the monospace font family name from the theme variant.
mono_font_size
Returns the monospace font size in pixels from the theme variant.
pick_variantDeprecated
Select light or dark variant from a native_theme::NativeTheme, with cross-fallback.
scrollbar_width
Returns the scrollbar width, checking geometry first, then widget metrics.
to_theme
Create an iced iced_core::theme::Theme from a native_theme::ThemeVariant.