native-theme-iced
iced toolkit connector for native-theme.
Maps native_theme::NativeTheme data to iced's theming system, producing a
fully configured iced::Theme with correct colors for all built-in widget
styles via iced's Catalog system.
Usage
Add both crates to your Cargo.toml:
[]
= "0.3"
= "0.3"
Then create an iced theme from any native-theme preset or OS theme:
use NativeTheme;
use to_theme;
// Load a preset
let nt = preset.unwrap;
// Pick light or dark variant (with cross-fallback)
let is_dark = true;
if let Some = nt.pick_variant
Or read the OS theme at runtime:
use ;
use to_theme;
let nt = from_system.unwrap_or_else;
let is_dark = true;
if let Some = nt.pick_variant
Widget Metrics
The crate exposes helper functions for widget sizing that iced applies per-widget rather than through the Catalog:
button_padding(variant)-- horizontal and vertical paddinginput_padding(variant)-- text input paddingborder_radius(variant)-- standard corner radiusborder_radius_lg(variant)-- large corner radius (e.g., dialogs)scrollbar_width(variant)-- scrollbar track widthfont_family(variant)-- primary UI font family namefont_size(variant)-- primary UI font size in pixels (converted from points)mono_font_family(variant)-- monospace font family namemono_font_size(variant)-- monospace font size in pixels
Modules
| Module | Purpose |
|---|---|
palette |
Maps native-theme colors to iced's 6-field Palette |
extended |
Overrides iced's Extended palette for secondary and background.weak |
icons |
Icon role mapping for iced SVG widgets |
Custom Icons
For app-specific icons defined via native-theme-build, the connector provides:
custom_icon_to_image_handle(provider, icon_set)-- load a custom icon as an iced image handlecustom_icon_to_svg_handle(provider, icon_set)-- load as an SVG handlecustom_icon_to_svg_handle_colored(provider, icon_set, color)-- load with color tinting
These work with any type implementing IconProvider.
Example
Run the showcase widget gallery to explore all 17 presets interactively:
The showcase displays all iced widgets (buttons, inputs, sliders, checkboxes, togglers, etc.) themed with native-theme presets, with live theme switching and a color map inspector.
License
Licensed under either of
at your option.