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() -> Self
pub fn catppuccin_mocha() -> Self
Catppuccin Mocha (dark).
Sourcepub fn catppuccin_latte() -> Self
pub fn catppuccin_latte() -> Self
Catppuccin Latte (light).
Sourcepub fn tokyo_night() -> Self
pub fn tokyo_night() -> Self
Tokyo Night (dark).
Sourcepub fn solarized_dark() -> Self
pub fn solarized_dark() -> Self
Solarized Dark.
Sourcepub fn solarized_light() -> Self
pub fn solarized_light() -> Self
Solarized Light.
Sourcepub fn default_light() -> Self
pub fn default_light() -> Self
Default Light (light, from gitkraft).
Sourcepub fn gruvbox_light() -> Self
pub fn gruvbox_light() -> Self
Gruvbox Light (light, from gitkraft).
Sourcepub fn catppuccin_frappe() -> Self
pub fn catppuccin_frappe() -> Self
Catppuccin Frappé (dark, from gitkraft).
Sourcepub fn catppuccin_macchiato() -> Self
pub fn catppuccin_macchiato() -> Self
Catppuccin Macchiato (dark, from gitkraft).
Sourcepub fn tokyo_night_storm() -> Self
pub fn tokyo_night_storm() -> Self
Tokyo Night Storm (dark, from gitkraft).
Sourcepub fn tokyo_night_light() -> Self
pub fn tokyo_night_light() -> Self
Tokyo Night Light (light, from gitkraft).
Sourcepub fn kanagawa_wave() -> Self
pub fn kanagawa_wave() -> Self
Kanagawa Wave (dark, from gitkraft).
Sourcepub fn kanagawa_dragon() -> Self
pub fn kanagawa_dragon() -> Self
Kanagawa Dragon (dark, from gitkraft).
Sourcepub fn kanagawa_lotus() -> Self
pub fn kanagawa_lotus() -> Self
Kanagawa Lotus (light, from gitkraft).
Sourcepub fn rose_pine_moon() -> Self
pub fn rose_pine_moon() -> Self
Rose Pine Moon (dark, from gitkraft).
Sourcepub fn rose_pine_dawn() -> Self
pub fn rose_pine_dawn() -> Self
Rose Pine Dawn (light, from gitkraft).
Sourcepub fn ayu_mirage() -> Self
pub fn ayu_mirage() -> Self
Ayu Mirage (dark, from gitkraft).
Sourcepub fn everforest_dark() -> Self
pub fn everforest_dark() -> Self
Everforest Dark (dark, from gitkraft).
Sourcepub fn atom_one_light() -> Self
pub fn atom_one_light() -> Self
Atom One Light (light, from gitkraft).
Sourcepub fn poimandres() -> Self
pub fn poimandres() -> Self
Poimandres (dark, from gitkraft).
Sourcepub fn flexoki_dark() -> Self
pub fn flexoki_dark() -> Self
Flexoki Dark (dark, from gitkraft).
Sourcepub fn flexoki_light() -> Self
pub fn flexoki_light() -> Self
Flexoki Light (light, from gitkraft).
Sourcepub fn github_dark() -> Self
pub fn github_dark() -> Self
Github Dark.
Sourcepub fn github_light() -> Self
pub fn github_light() -> Self
Github Light.
Sourcepub fn super_mario() -> Self
pub fn super_mario() -> Self
Super Mario.
Sourcepub fn tokyo_night_moon() -> Self
pub fn tokyo_night_moon() -> Self
Tokyo Night Moon.
Sourcepub fn tokyo_night_day() -> Self
pub fn tokyo_night_day() -> Self
Tokyo Night Day.
Sourcepub fn gruvbox_material() -> Self
pub fn gruvbox_material() -> Self
Gruvbox Material.
Sourcepub fn material_palenight() -> Self
pub fn material_palenight() -> Self
Material Palenight.
Sourcepub fn tomorrow_night() -> Self
pub fn tomorrow_night() -> Self
Tomorrow Night.
Sourcepub fn papercolor_light() -> Self
pub fn papercolor_light() -> Self
Papercolor Light.
Sourcepub fn synthwave_outrun() -> Self
pub fn synthwave_outrun() -> Self
Synthwave Outrun.
Sourcepub fn modus_vivendi() -> Self
pub fn modus_vivendi() -> Self
Modus Vivendi.
Sourcepub fn modus_operandi() -> Self
pub fn modus_operandi() -> Self
Modus Operandi.
Sourcepub fn clair_obscur() -> Self
pub fn clair_obscur() -> Self
Clair Obscur.
Sourcepub fn clair_obscur_canvas() -> Self
pub fn clair_obscur_canvas() -> Self
Clair Obscur Canvas.
Sourcepub fn mario_overworld() -> Self
pub fn mario_overworld() -> Self
Mario Overworld.
Sourcepub fn mario_underground() -> Self
pub fn mario_underground() -> Self
Mario Underground.
Sourcepub fn cavern_hush() -> Self
pub fn cavern_hush() -> Self
Cavern Hush.
Sourcepub fn test_chamber() -> Self
pub fn test_chamber() -> Self
Test Chamber.
Sourcepub fn underworld() -> Self
pub fn underworld() -> Self
Underworld.
Sourcepub fn everforest_light() -> Self
pub fn everforest_light() -> Self
Everforest Light.
Source§impl Theme
impl Theme
Sourcepub fn porsche() -> Self
pub fn porsche() -> Self
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() -> Self
pub fn colorblind() -> Self
Colorblind-safe theme (Okabe–Ito palette; blue/orange instead of green/red). Keeps the terminal background.
Sourcepub fn high_contrast() -> Self
pub fn high_contrast() -> Self
Maximum-contrast theme: pure black/white with saturated status colors.
Sourcepub fn mono() -> Self
pub fn mono() -> Self
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,
) -> Self
pub fn from_base( name: &str, background: Option<Color>, foreground: Color, accent: Color, bull: Color, bear: Color, ) -> Self
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]) -> Self
pub fn from_palette(name: &str, colors: &[Color]) -> Self
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>) -> Self
pub fn palette(self, palette: Vec<Color>) -> Self
Set the series palette (an empty palette is ignored).
Sourcepub fn background(self, background: Option<Color>) -> Self
pub fn background(self, background: Option<Color>) -> Self
Set (or clear) the background fill.
Sourcepub fn surface(self, surface: Option<Color>) -> Self
pub fn surface(self, surface: Option<Color>) -> Self
Set (or clear) the panel / card background.
Sourcepub fn foreground(self, color: Color) -> Self
pub fn foreground(self, color: Color) -> Self
Set the foreground color.
Sourcepub fn border_focused(self, color: Color) -> Self
pub fn border_focused(self, color: Color) -> Self
Set the border_focused color.
Sourcepub fn selection_bg(self, color: Color) -> Self
pub fn selection_bg(self, color: Color) -> Self
Set the selection_bg color.
Sourcepub fn selection_fg(self, color: Color) -> Self
pub fn selection_fg(self, color: Color) -> Self
Set the selection_fg color.
Sourcepub fn tooltip_fg(self, color: Color) -> Self
pub fn tooltip_fg(self, color: Color) -> Self
Set the tooltip_fg color.
Sourcepub fn tooltip_bg(self, color: Color) -> Self
pub fn tooltip_bg(self, color: Color) -> Self
Set the tooltip_bg color.
Sourcepub fn tooltip(self, fg: Color, bg: Color) -> Self
pub fn tooltip(self, fg: Color, bg: Color) -> Self
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