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 themeModules§
- extended
- Extended palette overrides from
native_theme::ResolvedThemefields. - icons
- Icon conversion helpers for iced.
- palette
- Maps
native_theme::ResolvedThemecolors to aniced_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_
variant Deprecated - 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::Themefrom anative_theme::ResolvedTheme.