Skip to main content

Crate native_theme_iced

Crate native_theme_iced 

Source
Expand description

iced toolkit connector for native-theme.

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

§Overview

This crate provides a thin mapping layer from native_theme::ResolvedTheme 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("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");
// Use `theme` as your iced application theme

Modules§

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

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 as [horizontal, vertical] from the resolved theme.
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.
input_padding
Returns text input padding as [horizontal, vertical] 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.
pick_variantDeprecated
Select light or dark variant from a native_theme::NativeTheme, with cross-fallback.
scrollbar_width
Returns the scrollbar width from the resolved theme.
to_theme
Create an iced iced_core::theme::Theme from a native_theme::ResolvedTheme.