Expand description
SalsaTheme provides a styling system for ratatui apps.
It has a flat mapping from style-name to either a ratatui Style
or to one of the composite styles used by rat-widget.
And it contains the underlying color Palette.
§Naming styles
-
It has an extension trait for Style that adds constants for known styles. In the same manner you can add your application specific styles and have them with code completion.
-
For rat-widget composite style it defines an anchor struct WidgetStyle that performs the same purpose.
§Usage
// ratatui Style
let s: Style = theme.style(Style::SELECT);
// composite style
Checkbox::new()
.styles(theme.style(WidgetStyle::CHECKBOX))
.render(area, buf, &mut state);§Palette
Palette holds the color definitions and aliases for the
colors. This is the part of the theme that can be persisted.
It can be stored/loaded from file or put into a static.
With create_palette_theme the theme can be reconstructed.
let mut f = File::open("dark_palettes/base16.pal").expect("pal-file");
let pal = load_palette(f).expect("valid_pal-file");
let theme = match create_palette_theme(pal) {
Ok(r) => r,
Err(p) => panic!("unsupported theme {:?}", p.theme),
};
let s: Style = theme.style(Style::INPUT);
Modules§
- palette
- Palette is the color palette for salsa-themes.
- palettes
- Currently shipped palettes.
- theme
- SalsaTheme is the main structure for themes.
- themes
Structs§
- Load
Palette Err - Widget
Style - Anchor struct for the names of composite styles used by rat-widget’s.
Traits§
- RatWidget
Color - Extension trait for Color that defines standard names used by rat-theme to define color-aliases.
- Style
Name - Extension trait for Style that defines some standard names used by rat-theme/rat-widget
Functions§
- create_
palette Deprecated - Create one of the predefined themes as a Palette.
- create_
palette_ theme - Create the Theme based on the given Palette.
- create_
salsa_ palette - Create one of the predefined themes as a Palette.
- create_
salsa_ theme - Create one of the predefined themes.
- create_
theme Deprecated - load_
palette - Load a .pal file as a Palette.
- log_
style_ define - Log style definition. May help debugging styling problems …
- salsa_
palettes Deprecated - All predefined rat-salsa themes.
- salsa_
themes - All predefined rat-salsa themes.
- store_
palette - Stora a Palette as a .pal file.