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,infoacross 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
| Theme | Type | Description |
|---|---|---|
| Dracula | Dark | Iconic dark purple aesthetic |
| One Dark Pro | Dark | Atom’s beloved dark theme |
| Nord | Dark | Arctic, bluish color palette |
| Catppuccin Mocha | Dark | Warm, soothing pastel dark |
| Catppuccin Latte | Light | Warm pastel light variant |
| Gruvbox Dark | Dark | Retro groove colors |
| Gruvbox Light | Light | Retro groove, light mode |
| Tokyo Night | Dark | Futuristic Tokyo cityscape |
| Solarized Dark | Dark | Precision-engineered colors |
| Solarized Light | Light | Solarized for bright rooms |
| Monokai Pro | Dark | Classic syntax colors |
| Rosé Pine | Dark | Natural, muted elegance |
| Kanagawa | Dark | Inspired by Hokusai’s art |
| Everforest | Dark | Comfortable forest green |
| Cyberpunk | Dark | Neon-soaked futuristic |
§Feature Flags
serde(enabled by default) — Enables serialization/deserialization of theme nameswidgets— Provides ready-to-use widgets likeThemePicker
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
Styletype for convenience. - Theme
- A theme configuration wrapper providing convenient access to theme colors.
- Theme
Palette - A semantic color palette for a theme.