pub fn from_iced_theme(theme: &Theme) -> StyleExpand description
Creates a theme style automatically from any Iced theme.
This is the default styling function that adapts to all native Iced themes including:
- Basic themes: Light, Dark
- Popular themes: Dracula, Nord, Solarized, Gruvbox
- Catppuccin variants: Latte, Frappé, Macchiato, Mocha
- Tokyo Night variants: Tokyo Night, Storm, Light
- Kanagawa variants: Wave, Dragon, Lotus
- And more: Moonfly, Nightfly, Oxocarbon, Ferra
The function automatically detects if the theme is dark or light and adjusts colors accordingly for optimal contrast and readability in code editing.
§Color Mapping
background: Uses the theme’s base background colortext_color: Uses the theme’s base text colorgutter_background: Slightly darker/lighter than backgroundgutter_border: Border between gutter and editorline_number_color: Dimmed text color for subtle line numbersscrollbar_background: Matches editor backgroundscroller_color: Uses secondary color for visibilitycurrent_line_highlight: Subtle highlight using primary color
§Example
use iced_code_editor::theme;
let tokyo_night = iced::Theme::TokyoNightStorm;
let style = theme::from_iced_theme(&tokyo_night);
// Or use with any theme variant
let dracula = iced::Theme::Dracula;
let style = theme::from_iced_theme(&dracula);