pub struct Theme {Show 28 fields
pub name: String,
pub background: Option<Color>,
pub surface: Option<Color>,
pub foreground: Color,
pub muted: Color,
pub disabled: Color,
pub border: Color,
pub border_focused: Color,
pub title: Color,
pub primary: Color,
pub secondary: Color,
pub accent: Color,
pub success: Color,
pub warning: Color,
pub error: Color,
pub info: Color,
pub selection_bg: Color,
pub selection_fg: Color,
pub highlight: Color,
pub palette: Vec<Color>,
pub bull: Color,
pub bear: Color,
pub neutral: Color,
pub axis: Color,
pub grid: Color,
pub crosshair: Color,
pub tooltip_fg: Color,
pub tooltip_bg: Color,
}Expand description
A named set of colors shared by every widget of an application.
The first group of fields (foreground … highlight) is the general UI
vocabulary; the second group (palette … tooltip_bg) are the data
visualisation colors, kept under the same names tui-chart used so
migrating is a rename of the import.
With the serde feature a theme (de)serialises as a flat map of
"#rrggbb" / color-name strings; missing keys fall back to
Theme::default, and unset background/surface are omitted.
Fields§
§name: StringDisplay name (also used by Theme::next / Theme::prev).
background: Option<Color>Background fill; None keeps the terminal background.
surface: Option<Color>Panel / card background; None means “same as background”.
foreground: ColorDefault text color.
muted: ColorDe-emphasised text (hints, tick labels, legends).
disabled: ColorText of disabled elements.
border: ColorUnfocused border color.
border_focused: ColorFocused border color.
title: ColorTitle color.
primary: ColorMain brand / interaction color.
secondary: ColorSecondary brand color.
accent: ColorAccent color (single-series charts, gradients, highlights).
success: ColorPositive status color.
warning: ColorWarning status color.
error: ColorError status color.
info: ColorInformational status color.
selection_bg: ColorBackground of the selected item.
selection_fg: ColorForeground of the selected item.
highlight: ColorHighlight color (search matches, markers).
palette: Vec<Color>Series palette (at least 8 colors); series i uses palette[i % len].
bull: Color“Up” color (bullish candles, bids, increases).
bear: Color“Down” color (bearish candles, asks, decreases).
neutral: ColorNeutral / total color.
axis: ColorAxis line color.
grid: ColorGrid line color.
crosshair: ColorCrosshair guide line color.
tooltip_fg: ColorCrosshair tooltip text color.
tooltip_bg: ColorCrosshair tooltip background color.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn catppuccin_mocha() -> Theme
pub fn catppuccin_mocha() -> Theme
Catppuccin Mocha (dark).
Sourcepub fn catppuccin_latte() -> Theme
pub fn catppuccin_latte() -> Theme
Catppuccin Latte (light).
Sourcepub fn tokyo_night() -> Theme
pub fn tokyo_night() -> Theme
Tokyo Night (dark).
Sourcepub fn solarized_dark() -> Theme
pub fn solarized_dark() -> Theme
Solarized Dark.
Sourcepub fn solarized_light() -> Theme
pub fn solarized_light() -> Theme
Solarized Light.
Sourcepub fn default_light() -> Theme
pub fn default_light() -> Theme
Default Light (light, from gitkraft).
Sourcepub fn gruvbox_light() -> Theme
pub fn gruvbox_light() -> Theme
Gruvbox Light (light, from gitkraft).
Sourcepub fn catppuccin_frappe() -> Theme
pub fn catppuccin_frappe() -> Theme
Catppuccin Frappé (dark, from gitkraft).
Sourcepub fn catppuccin_macchiato() -> Theme
pub fn catppuccin_macchiato() -> Theme
Catppuccin Macchiato (dark, from gitkraft).
Sourcepub fn tokyo_night_storm() -> Theme
pub fn tokyo_night_storm() -> Theme
Tokyo Night Storm (dark, from gitkraft).
Sourcepub fn tokyo_night_light() -> Theme
pub fn tokyo_night_light() -> Theme
Tokyo Night Light (light, from gitkraft).
Sourcepub fn kanagawa_wave() -> Theme
pub fn kanagawa_wave() -> Theme
Kanagawa Wave (dark, from gitkraft).
Sourcepub fn kanagawa_dragon() -> Theme
pub fn kanagawa_dragon() -> Theme
Kanagawa Dragon (dark, from gitkraft).
Sourcepub fn kanagawa_lotus() -> Theme
pub fn kanagawa_lotus() -> Theme
Kanagawa Lotus (light, from gitkraft).
Sourcepub fn rose_pine_moon() -> Theme
pub fn rose_pine_moon() -> Theme
Rose Pine Moon (dark, from gitkraft).
Sourcepub fn rose_pine_dawn() -> Theme
pub fn rose_pine_dawn() -> Theme
Rose Pine Dawn (light, from gitkraft).
Sourcepub fn ayu_mirage() -> Theme
pub fn ayu_mirage() -> Theme
Ayu Mirage (dark, from gitkraft).
Sourcepub fn everforest_dark() -> Theme
pub fn everforest_dark() -> Theme
Everforest Dark (dark, from gitkraft).
Sourcepub fn atom_one_light() -> Theme
pub fn atom_one_light() -> Theme
Atom One Light (light, from gitkraft).
Sourcepub fn poimandres() -> Theme
pub fn poimandres() -> Theme
Poimandres (dark, from gitkraft).
Sourcepub fn flexoki_dark() -> Theme
pub fn flexoki_dark() -> Theme
Flexoki Dark (dark, from gitkraft).
Sourcepub fn flexoki_light() -> Theme
pub fn flexoki_light() -> Theme
Flexoki Light (light, from gitkraft).
Sourcepub fn github_dark() -> Theme
pub fn github_dark() -> Theme
Github Dark.
Sourcepub fn github_light() -> Theme
pub fn github_light() -> Theme
Github Light.
Sourcepub fn super_mario() -> Theme
pub fn super_mario() -> Theme
Super Mario.
Sourcepub fn tokyo_night_moon() -> Theme
pub fn tokyo_night_moon() -> Theme
Tokyo Night Moon.
Sourcepub fn tokyo_night_day() -> Theme
pub fn tokyo_night_day() -> Theme
Tokyo Night Day.
Sourcepub fn gruvbox_material() -> Theme
pub fn gruvbox_material() -> Theme
Gruvbox Material.
Sourcepub fn material_palenight() -> Theme
pub fn material_palenight() -> Theme
Material Palenight.
Sourcepub fn tomorrow_night() -> Theme
pub fn tomorrow_night() -> Theme
Tomorrow Night.
Sourcepub fn papercolor_light() -> Theme
pub fn papercolor_light() -> Theme
Papercolor Light.
Sourcepub fn synthwave_outrun() -> Theme
pub fn synthwave_outrun() -> Theme
Synthwave Outrun.
Sourcepub fn modus_vivendi() -> Theme
pub fn modus_vivendi() -> Theme
Modus Vivendi.
Sourcepub fn modus_operandi() -> Theme
pub fn modus_operandi() -> Theme
Modus Operandi.
Sourcepub fn clair_obscur() -> Theme
pub fn clair_obscur() -> Theme
Clair Obscur.
Sourcepub fn clair_obscur_canvas() -> Theme
pub fn clair_obscur_canvas() -> Theme
Clair Obscur Canvas.
Sourcepub fn mario_overworld() -> Theme
pub fn mario_overworld() -> Theme
Mario Overworld.
Sourcepub fn mario_underground() -> Theme
pub fn mario_underground() -> Theme
Mario Underground.
Sourcepub fn cavern_hush() -> Theme
pub fn cavern_hush() -> Theme
Cavern Hush.
Sourcepub fn test_chamber() -> Theme
pub fn test_chamber() -> Theme
Test Chamber.
Sourcepub fn underworld() -> Theme
pub fn underworld() -> Theme
Underworld.
Sourcepub fn everforest_light() -> Theme
pub fn everforest_light() -> Theme
Everforest Light.
Source§impl Theme
impl Theme
Sourcepub fn porsche() -> Theme
pub fn porsche() -> Theme
Porsche: black/white with the signature red accent (#D5001C).
Bull is white and bear is red, as in the Porsche chart look.
Sourcepub fn colorblind() -> Theme
pub fn colorblind() -> Theme
Colorblind-safe theme (Okabe–Ito palette; blue/orange instead of green/red). Keeps the terminal background.
Sourcepub fn high_contrast() -> Theme
pub fn high_contrast() -> Theme
Maximum-contrast theme: pure black/white with saturated status colors.
Sourcepub fn mono() -> Theme
pub fn mono() -> Theme
Monochrome theme for 1-bit-ish terminals: only white, gray and dark gray, terminal background. Selection is shown in reverse video colors.
Sourcepub fn by_name(name: &str) -> Option<Theme>
pub fn by_name(name: &str) -> Option<Theme>
Look a built-in theme up by name. Case-insensitive; _ and spaces
are accepted for - ("Tokyo Night" → tokyo-night).
Source§impl Theme
impl Theme
Sourcepub fn base_style(&self) -> Style
pub fn base_style(&self) -> Style
Alias of Theme::style (the name tui-chart used).
Sourcepub fn surface_style(&self) -> Style
pub fn surface_style(&self) -> Style
Style for panels / cards: foreground on surface (falls back to the background).
Sourcepub fn muted_style(&self) -> Style
pub fn muted_style(&self) -> Style
De-emphasised text style.
Sourcepub fn border_style(&self, focused: bool) -> Style
pub fn border_style(&self, focused: bool) -> Style
Border style; the focused variant uses border_focused and bold.
Sourcepub fn title_style(&self) -> Style
pub fn title_style(&self) -> Style
Title style (bold).
Sourcepub fn selected_style(&self) -> Style
pub fn selected_style(&self) -> Style
Style of the selected item: selection_fg on selection_bg.
Sourcepub fn disabled_style(&self) -> Style
pub fn disabled_style(&self) -> Style
Style of disabled elements.
Sourcepub fn highlight_style(&self) -> Style
pub fn highlight_style(&self) -> Style
Style of search matches / markers: highlight color, bold.
Sourcepub fn status_color(&self, status: Status) -> Color
pub fn status_color(&self, status: Status) -> Color
Color for a Status.
Sourcepub fn status_style(&self, status: Status) -> Style
pub fn status_style(&self, status: Status) -> Style
Style for a Status (its color as foreground).
Sourcepub fn axis_style(&self) -> Style
pub fn axis_style(&self) -> Style
Axis line style.
Sourcepub fn label_style(&self) -> Style
pub fn label_style(&self) -> Style
Tick / legend label style (same color as muted).
Sourcepub fn grid_style(&self) -> Style
pub fn grid_style(&self) -> Style
Grid line style.
Sourcepub fn tooltip_style(&self) -> Style
pub fn tooltip_style(&self) -> Style
Tooltip style: tooltip_fg on tooltip_bg.
Source§impl Theme
impl Theme
Sourcepub fn downgrade(&self, support: ColorSupport) -> Theme
pub fn downgrade(&self, support: ColorSupport) -> Theme
Reduce every color of the theme to what support can display.
TrueColor is a no-op, Ansi256 maps RGB to Color::Indexed,
Ansi16 maps everything to the 16 named colors and None resets all
colors (and clears background/surface) so the terminal default is used.
Sourcepub fn downgrade_for_terminal(&self) -> Theme
pub fn downgrade_for_terminal(&self) -> Theme
Source§impl Theme
impl Theme
Sourcepub fn from_base(
name: &str,
background: Option<Color>,
foreground: Color,
accent: Color,
bull: Color,
bear: Color,
) -> Theme
pub fn from_base( name: &str, background: Option<Color>, foreground: Color, accent: Color, bull: Color, bear: Color, ) -> Theme
Build a theme from the handful of colors an application already has.
Everything else is derived: RGB (and named/indexed) colors are blended
between background (black when None) and foreground, so muted
text, grid, borders, disabled text, surface and selection stay in
tune. Success/bull use bull, error/bear use bear, primary/accent use
accent; the palette starts with accent, bull, bear. Use the builder
setters afterwards to fine-tune.
use ratatui::style::Color;
use tui_nuances::Theme;
let t = Theme::from_base(
"app",
Some(Color::Rgb(16, 16, 24)),
Color::Rgb(230, 230, 240),
Color::Rgb(213, 0, 28),
Color::Green,
Color::Red,
);
assert_eq!(t.primary, Color::Rgb(213, 0, 28));
assert!(t.palette.len() >= 8);Sourcepub fn from_palette(name: &str, colors: &[Color]) -> Theme
pub fn from_palette(name: &str, colors: &[Color]) -> Theme
Build a theme from just a series palette (terminal background, white text). The first three colors become accent / bull / bear; the palette is cycled up to at least 8 entries. An empty slice yields the default palette.
use ratatui::style::Color;
use tui_nuances::Theme;
let t = Theme::from_palette("pair", &[Color::Red, Color::Blue]);
assert_eq!(t.palette.len(), 8);
assert_eq!(t.color(2), Color::Red);Sourcepub fn colors(&self) -> Vec<Color>
pub fn colors(&self) -> Vec<Color>
Every color of the theme (background and surface included when set, palette last). Handy for audits and tests.
Sourcepub fn palette(self, palette: Vec<Color>) -> Theme
pub fn palette(self, palette: Vec<Color>) -> Theme
Set the series palette (an empty palette is ignored).
Sourcepub fn background(self, background: Option<Color>) -> Theme
pub fn background(self, background: Option<Color>) -> Theme
Set (or clear) the background fill.
Sourcepub fn surface(self, surface: Option<Color>) -> Theme
pub fn surface(self, surface: Option<Color>) -> Theme
Set (or clear) the panel / card background.
Sourcepub fn foreground(self, color: Color) -> Theme
pub fn foreground(self, color: Color) -> Theme
Set the foreground color.
Sourcepub fn border_focused(self, color: Color) -> Theme
pub fn border_focused(self, color: Color) -> Theme
Set the border_focused color.
Sourcepub fn selection_bg(self, color: Color) -> Theme
pub fn selection_bg(self, color: Color) -> Theme
Set the selection_bg color.
Sourcepub fn selection_fg(self, color: Color) -> Theme
pub fn selection_fg(self, color: Color) -> Theme
Set the selection_fg color.
Sourcepub fn tooltip_fg(self, color: Color) -> Theme
pub fn tooltip_fg(self, color: Color) -> Theme
Set the tooltip_fg color.
Sourcepub fn tooltip_bg(self, color: Color) -> Theme
pub fn tooltip_bg(self, color: Color) -> Theme
Set the tooltip_bg color.
Sourcepub fn tooltip(self, fg: Color, bg: Color) -> Theme
pub fn tooltip(self, fg: Color, bg: Color) -> Theme
Set the tooltip foreground/background colors.
Trait Implementations§
impl StructuralPartialEq for Theme
Source§impl ThemeProvider for Theme
impl ThemeProvider for Theme
Source§fn nuance_theme(&self) -> Theme
fn nuance_theme(&self) -> Theme
Theme for this application theme.Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more