Skip to main content

Crate ratatui_themes

Crate ratatui_themes 

Source
Expand description

§ratatui-themes

A collection of popular color themes for ratatui terminal UI applications.

This crate provides a consistent, easy-to-use API for applying beautiful color schemes to your terminal user interfaces. Each theme includes semantic colors for common UI elements like errors, warnings, and highlights.

§Features

  • 15+ popular themes — Dracula, Nord, Catppuccin, Gruvbox, Tokyo Night, and more
  • Semantic colors — Consistent error, warning, success, info across all themes
  • Easy theme cycling — Built-in next()/prev() methods for theme switchers
  • Light/dark detection — Programmatically determine if a theme is light or dark
  • Serde support — Optional serialization for saving theme preferences (enabled by default)

§Quick Start

use ratatui_themes::{Theme, ThemeName};
use ratatui::style::Style;

// Create a theme
let theme = Theme::new(ThemeName::Dracula);

// Access the color palette
let palette = theme.palette();

// Apply colors to styles
let title_style = Style::default()
    .fg(palette.accent)
    .bg(palette.bg);

let error_style = Style::default().fg(palette.error);
let muted_text = Style::default().fg(palette.muted);

§Theme Cycling

Easily implement theme switching in your application:

use ratatui_themes::ThemeName;

let mut current = ThemeName::Dracula;

// Cycle forward through all themes
current = current.next();  // -> OneDarkPro

// Cycle backward
current = current.prev();  // -> Dracula

// Get all available themes for a selection menu
let all_themes = ThemeName::all();

§Configuration with Serde

Save and load theme preferences (requires the serde feature, enabled by default):

use ratatui_themes::ThemeName;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct AppConfig {
    theme: ThemeName,
    // ... other settings
}

// Theme names serialize as kebab-case strings:
// { "theme": "tokyo-night" }

§Available Themes

ThemeTypeDescription
DraculaDarkIconic dark purple aesthetic
One Dark ProDarkAtom’s beloved dark theme
NordDarkArctic, bluish color palette
Catppuccin MochaDarkWarm, soothing pastel dark
Catppuccin LatteLightWarm pastel light variant
Gruvbox DarkDarkRetro groove colors
Gruvbox LightLightRetro groove, light mode
Tokyo NightDarkFuturistic Tokyo cityscape
Solarized DarkDarkPrecision-engineered colors
Solarized LightLightSolarized for bright rooms
Monokai ProDarkClassic syntax colors
Rosé PineDarkNatural, muted elegance
KanagawaDarkInspired by Hokusai’s art
EverforestDarkComfortable forest green
CyberpunkDarkNeon-soaked futuristic

§Feature Flags

  • serde (enabled by default) — Enables serialization/deserialization of theme names
  • widgets — Provides ready-to-use widgets like ThemePicker

To disable serde support:

[dependencies]
ratatui-themes = { version = "0.1", default-features = false }

Re-exports§

pub use widgets::ThemePicker;

Modules§

widgets
Enable included widgets. Optional widgets for theme selection and display.

Structs§

Style
Re-export ratatui’s Style type for convenience.
Theme
A theme configuration wrapper providing convenient access to theme colors.
ThemePalette
A semantic color palette for a theme.

Enums§

Color
Re-export ratatui’s Color type for convenience.
ThemeName
Enumeration of all available color themes.