Skip to main content

Theme

Struct Theme 

Source
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: String

Display 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: Color

Default text color.

§muted: Color

De-emphasised text (hints, tick labels, legends).

§disabled: Color

Text of disabled elements.

§border: Color

Unfocused border color.

§border_focused: Color

Focused border color.

§title: Color

Title color.

§primary: Color

Main brand / interaction color.

§secondary: Color

Secondary brand color.

§accent: Color

Accent color (single-series charts, gradients, highlights).

§success: Color

Positive status color.

§warning: Color

Warning status color.

§error: Color

Error status color.

§info: Color

Informational status color.

§selection_bg: Color

Background of the selected item.

§selection_fg: Color

Foreground of the selected item.

§highlight: Color

Highlight 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: Color

Neutral / total color.

§axis: Color

Axis line color.

§grid: Color

Grid line color.

§crosshair: Color

Crosshair guide line color.

§tooltip_fg: Color

Crosshair tooltip text color.

§tooltip_bg: Color

Crosshair tooltip background color.

Implementations§

Source§

impl Theme

Source

pub fn catppuccin_mocha() -> Theme

Catppuccin Mocha (dark).

Source

pub fn catppuccin_latte() -> Theme

Catppuccin Latte (light).

Source

pub fn dracula() -> Theme

Dracula (dark).

Source

pub fn nord() -> Theme

Nord (dark, arctic blues).

Source

pub fn gruvbox() -> Theme

Gruvbox (dark, warm retro).

Source

pub fn tokyo_night() -> Theme

Tokyo Night (dark).

Source

pub fn solarized_dark() -> Theme

Solarized Dark.

Source

pub fn solarized_light() -> Theme

Solarized Light.

Source

pub fn one_dark() -> Theme

One Dark (Atom).

Source

pub fn rose_pine() -> Theme

Rosé Pine (dark).

Source

pub fn monokai() -> Theme

Monokai (dark).

Source

pub fn default_light() -> Theme

Default Light (light, from gitkraft).

Source

pub fn grape() -> Theme

Grape (dark, from gitkraft).

Source

pub fn ocean() -> Theme

Ocean (dark, from gitkraft).

Source

pub fn sunset() -> Theme

Sunset (dark, from gitkraft).

Source

pub fn forest() -> Theme

Forest (dark, from gitkraft).

Source

pub fn rose() -> Theme

Rose (dark, from gitkraft).

Source

pub fn neon() -> Theme

Neon (dark, from gitkraft).

Source

pub fn gruvbox_light() -> Theme

Gruvbox Light (light, from gitkraft).

Source

pub fn catppuccin_frappe() -> Theme

Catppuccin Frappé (dark, from gitkraft).

Source

pub fn catppuccin_macchiato() -> Theme

Catppuccin Macchiato (dark, from gitkraft).

Source

pub fn tokyo_night_storm() -> Theme

Tokyo Night Storm (dark, from gitkraft).

Source

pub fn tokyo_night_light() -> Theme

Tokyo Night Light (light, from gitkraft).

Source

pub fn kanagawa_wave() -> Theme

Kanagawa Wave (dark, from gitkraft).

Source

pub fn kanagawa_dragon() -> Theme

Kanagawa Dragon (dark, from gitkraft).

Source

pub fn kanagawa_lotus() -> Theme

Kanagawa Lotus (light, from gitkraft).

Source

pub fn moonfly() -> Theme

Moonfly (dark, from gitkraft).

Source

pub fn nightfly() -> Theme

Nightfly (dark, from gitkraft).

Source

pub fn oxocarbon() -> Theme

Oxocarbon (dark, from gitkraft).

Source

pub fn cyberpunk() -> Theme

Cyberpunk (dark, from gitkraft).

Source

pub fn rose_pine_moon() -> Theme

Rose Pine Moon (dark, from gitkraft).

Source

pub fn rose_pine_dawn() -> Theme

Rose Pine Dawn (light, from gitkraft).

Source

pub fn ayu_mirage() -> Theme

Ayu Mirage (dark, from gitkraft).

Source

pub fn everforest_dark() -> Theme

Everforest Dark (dark, from gitkraft).

Source

pub fn atom_one_light() -> Theme

Atom One Light (light, from gitkraft).

Source

pub fn night_owl() -> Theme

Night Owl (dark, from gitkraft).

Source

pub fn poimandres() -> Theme

Poimandres (dark, from gitkraft).

Source

pub fn flexoki_dark() -> Theme

Flexoki Dark (dark, from gitkraft).

Source

pub fn flexoki_light() -> Theme

Flexoki Light (light, from gitkraft).

Source

pub fn carbonfox() -> Theme

Carbonfox (dark, from gitkraft).

Source

pub fn andromeda() -> Theme

Andromeda (dark, from gitkraft).

Source

pub fn synthwave() -> Theme

Synthwave (dark, from gitkraft).

Source

pub fn ayu_dark() -> Theme

Ayu Dark.

Source

pub fn github_dark() -> Theme

Github Dark.

Source

pub fn github_light() -> Theme

Github Light.

Source

pub fn zenburn() -> Theme

Zenburn.

Source

pub fn super_mario() -> Theme

Super Mario.

Source

pub fn tokyo_night_moon() -> Theme

Tokyo Night Moon.

Source

pub fn tokyo_night_day() -> Theme

Tokyo Night Day.

Source

pub fn gruvbox_material() -> Theme

Gruvbox Material.

Source

pub fn nightfox() -> Theme

Nightfox.

Source

pub fn dawnfox() -> Theme

Dawnfox.

Source

pub fn melange() -> Theme

Melange.

Source

pub fn material_palenight() -> Theme

Material Palenight.

Source

pub fn tomorrow_night() -> Theme

Tomorrow Night.

Source

pub fn snazzy() -> Theme

Snazzy.

Source

pub fn iceberg() -> Theme

Iceberg.

Source

pub fn papercolor_light() -> Theme

Papercolor Light.

Source

pub fn synthwave_outrun() -> Theme

Synthwave Outrun.

Source

pub fn cobalt() -> Theme

Cobalt.

Source

pub fn modus_vivendi() -> Theme

Modus Vivendi.

Source

pub fn modus_operandi() -> Theme

Modus Operandi.

Source

pub fn horizon() -> Theme

Horizon.

Source

pub fn sonokai() -> Theme

Sonokai.

Source

pub fn clair_obscur() -> Theme

Clair Obscur.

Source

pub fn clair_obscur_canvas() -> Theme

Clair Obscur Canvas.

Source

pub fn mario_overworld() -> Theme

Mario Overworld.

Source

pub fn mario_underground() -> Theme

Mario Underground.

Source

pub fn pip_boy() -> Theme

Pip Boy.

Source

pub fn tarnished() -> Theme

Tarnished.

Source

pub fn hyrule() -> Theme

Hyrule.

Source

pub fn doom() -> Theme

Doom.

Source

pub fn phantom() -> Theme

Phantom.

Source

pub fn cavern_hush() -> Theme

Cavern Hush.

Source

pub fn test_chamber() -> Theme

Test Chamber.

Source

pub fn ember() -> Theme

Ember.

Source

pub fn meadow() -> Theme

Meadow.

Source

pub fn dojo() -> Theme

Dojo.

Source

pub fn underworld() -> Theme

Underworld.

Source

pub fn summit() -> Theme

Summit.

Source

pub fn rain_noir() -> Theme

Rain Noir.

Source

pub fn blocky() -> Theme

Blocky.

Source

pub fn everforest_light() -> Theme

Everforest Light.

Source

pub fn ayu_light() -> Theme

Ayu Light.

Source

pub fn duskfox() -> Theme

Duskfox.

Source§

impl Theme

Source

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.

Source

pub fn colorblind() -> Theme

Colorblind-safe theme (Okabe–Ito palette; blue/orange instead of green/red). Keeps the terminal background.

Source

pub fn high_contrast() -> Theme

Maximum-contrast theme: pure black/white with saturated status colors.

Source

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.

Source

pub fn all() -> Vec<Theme>

All built-in themes, in cycling order.

Source

pub fn names() -> Vec<&'static str>

Names of all built-in themes, in cycling order.

Source

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

pub fn next(&self) -> Theme

The next built-in theme (wraps). Custom-named themes start at default.

Source

pub fn prev(&self) -> Theme

The previous built-in theme (wraps). Custom-named themes start at the last one.

Source§

impl Theme

Source

pub fn style(&self) -> Style

Base style: foreground (+ background when set).

Source

pub fn base_style(&self) -> Style

Alias of Theme::style (the name tui-chart used).

Source

pub fn surface_style(&self) -> Style

Style for panels / cards: foreground on surface (falls back to the background).

Source

pub fn muted_style(&self) -> Style

De-emphasised text style.

Source

pub fn border_style(&self, focused: bool) -> Style

Border style; the focused variant uses border_focused and bold.

Source

pub fn title_style(&self) -> Style

Title style (bold).

Source

pub fn selected_style(&self) -> Style

Style of the selected item: selection_fg on selection_bg.

Source

pub fn disabled_style(&self) -> Style

Style of disabled elements.

Source

pub fn highlight_style(&self) -> Style

Style of search matches / markers: highlight color, bold.

Source

pub fn status_color(&self, status: Status) -> Color

Color for a Status.

Source

pub fn status_style(&self, status: Status) -> Style

Style for a Status (its color as foreground).

Source

pub fn axis_style(&self) -> Style

Axis line style.

Source

pub fn label_style(&self) -> Style

Tick / legend label style (same color as muted).

Source

pub fn grid_style(&self) -> Style

Grid line style.

Source

pub fn tooltip_style(&self) -> Style

Tooltip style: tooltip_fg on tooltip_bg.

Source

pub fn fill(&self, area: Rect, buf: &mut Buffer)

Fill area with the theme background (no-op when there is none).

Source§

impl Theme

Source

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.

Source

pub fn downgrade_for_terminal(&self) -> Theme

Source§

impl Theme

Source

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);
Source

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);
Source

pub fn colors(&self) -> Vec<Color>

Every color of the theme (background and surface included when set, palette last). Handy for audits and tests.

Source

pub fn name(self, name: impl Into<String>) -> Theme

Set the display name.

Source

pub fn palette(self, palette: Vec<Color>) -> Theme

Set the series palette (an empty palette is ignored).

Source

pub fn background(self, background: Option<Color>) -> Theme

Set (or clear) the background fill.

Source

pub fn surface(self, surface: Option<Color>) -> Theme

Set (or clear) the panel / card background.

Source

pub fn foreground(self, color: Color) -> Theme

Set the foreground color.

Source

pub fn muted(self, color: Color) -> Theme

Set the muted color.

Source

pub fn disabled(self, color: Color) -> Theme

Set the disabled color.

Source

pub fn border(self, color: Color) -> Theme

Set the border color.

Source

pub fn border_focused(self, color: Color) -> Theme

Set the border_focused color.

Source

pub fn title(self, color: Color) -> Theme

Set the title color.

Source

pub fn primary(self, color: Color) -> Theme

Set the primary color.

Source

pub fn secondary(self, color: Color) -> Theme

Set the secondary color.

Source

pub fn accent(self, color: Color) -> Theme

Set the accent color.

Source

pub fn success(self, color: Color) -> Theme

Set the success color.

Source

pub fn warning(self, color: Color) -> Theme

Set the warning color.

Source

pub fn error(self, color: Color) -> Theme

Set the error color.

Source

pub fn info(self, color: Color) -> Theme

Set the info color.

Source

pub fn selection_bg(self, color: Color) -> Theme

Set the selection_bg color.

Source

pub fn selection_fg(self, color: Color) -> Theme

Set the selection_fg color.

Source

pub fn highlight(self, color: Color) -> Theme

Set the highlight color.

Source

pub fn bull(self, color: Color) -> Theme

Set the bull color.

Source

pub fn bear(self, color: Color) -> Theme

Set the bear color.

Source

pub fn neutral(self, color: Color) -> Theme

Set the neutral color.

Source

pub fn axis(self, color: Color) -> Theme

Set the axis color.

Source

pub fn grid(self, color: Color) -> Theme

Set the grid color.

Source

pub fn crosshair(self, color: Color) -> Theme

Set the crosshair color.

Source

pub fn tooltip_fg(self, color: Color) -> Theme

Set the tooltip_fg color.

Source

pub fn tooltip_bg(self, color: Color) -> Theme

Set the tooltip_bg color.

Source

pub fn tooltip(self, fg: Color, bg: Color) -> Theme

Set the tooltip foreground/background colors.

Source

pub fn selection(self, fg: Color, bg: Color) -> Theme

Set the selection foreground/background colors.

Source

pub fn color(&self, i: usize) -> Color

Palette color for series i (cycles; falls back to accent if empty).

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Theme

Source§

fn default() -> Theme

Terminal-native theme built from named ANSI colors only.

Source§

impl From<&Theme> for Theme

Source§

fn from(t: &Theme) -> Theme

Converts to this type from the input type.
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Theme) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Theme

Source§

impl ThemeProvider for Theme

Source§

fn nuance_theme(&self) -> Theme

Produce the shared 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.