ratatui_themes/lib.rs
1//! # ratatui-themes
2//!
3//! A collection of popular color themes for [ratatui](https://ratatui.rs) terminal UI applications.
4//!
5//! This crate provides a consistent, easy-to-use API for applying beautiful color schemes
6//! to your terminal user interfaces. Each theme includes semantic colors for common UI
7//! elements like errors, warnings, and highlights.
8//!
9//! ## Features
10//!
11//! - **15+ popular themes** — Dracula, Nord, Catppuccin, Gruvbox, Tokyo Night, and more
12//! - **Semantic colors** — Consistent `error`, `warning`, `success`, `info` across all themes
13//! - **Easy theme cycling** — Built-in `next()`/`prev()` methods for theme switchers
14//! - **Light/dark detection** — Programmatically determine if a theme is light or dark
15//! - **Serde support** — Optional serialization for saving theme preferences (enabled by default)
16//!
17//! ## Quick Start
18//!
19//! ```rust
20//! use ratatui_themes::{Theme, ThemeName};
21//! use ratatui::style::Style;
22//!
23//! // Create a theme
24//! let theme = Theme::new(ThemeName::Dracula);
25//!
26//! // Access the color palette
27//! let palette = theme.palette();
28//!
29//! // Apply colors to styles
30//! let title_style = Style::default()
31//! .fg(palette.accent)
32//! .bg(palette.bg);
33//!
34//! let error_style = Style::default().fg(palette.error);
35//! let muted_text = Style::default().fg(palette.muted);
36//! ```
37//!
38//! ## Theme Cycling
39//!
40//! Easily implement theme switching in your application:
41//!
42//! ```rust
43//! use ratatui_themes::ThemeName;
44//!
45//! let mut current = ThemeName::Dracula;
46//!
47//! // Cycle forward through all themes
48//! current = current.next(); // -> OneDarkPro
49//!
50//! // Cycle backward
51//! current = current.prev(); // -> Dracula
52//!
53//! // Get all available themes for a selection menu
54//! let all_themes = ThemeName::all();
55//! ```
56//!
57//! ## Configuration with Serde
58//!
59//! Save and load theme preferences (requires the `serde` feature, enabled by default):
60//!
61//! ```rust
62//! use ratatui_themes::ThemeName;
63//! use serde::{Deserialize, Serialize};
64//!
65//! #[derive(Serialize, Deserialize)]
66//! struct AppConfig {
67//! theme: ThemeName,
68//! // ... other settings
69//! }
70//!
71//! // Theme names serialize as kebab-case strings:
72//! // { "theme": "tokyo-night" }
73//! ```
74//!
75//! ## Available Themes
76//!
77//! | Theme | Type | Description |
78//! |-------|------|-------------|
79//! | Dracula | Dark | Iconic dark purple aesthetic |
80//! | One Dark Pro | Dark | Atom's beloved dark theme |
81//! | Nord | Dark | Arctic, bluish color palette |
82//! | Catppuccin Mocha | Dark | Warm, soothing pastel dark |
83//! | Catppuccin Latte | Light | Warm pastel light variant |
84//! | Gruvbox Dark | Dark | Retro groove colors |
85//! | Gruvbox Light | Light | Retro groove, light mode |
86//! | Tokyo Night | Dark | Futuristic Tokyo cityscape |
87//! | Solarized Dark | Dark | Precision-engineered colors |
88//! | Solarized Light | Light | Solarized for bright rooms |
89//! | Monokai Pro | Dark | Classic syntax colors |
90//! | Rosé Pine | Dark | Natural, muted elegance |
91//! | Kanagawa | Dark | Inspired by Hokusai's art |
92//! | Everforest | Dark | Comfortable forest green |
93//! | Cyberpunk | Dark | Neon-soaked futuristic |
94//!
95//! ## Feature Flags
96//!
97//! - **`serde`** (enabled by default) — Enables serialization/deserialization of theme names
98//! - **`widgets`** — Provides ready-to-use widgets like [`ThemePicker`]
99//!
100//! To disable serde support:
101//!
102//! ```toml
103//! [dependencies]
104//! ratatui-themes = { version = "0.1", default-features = false }
105//! ```
106
107#![doc(html_root_url = "https://docs.rs/ratatui-themes/0.1.1")]
108#![warn(
109 missing_docs,
110 missing_debug_implementations,
111 rust_2018_idioms,
112 unreachable_pub,
113 clippy::all,
114 clippy::pedantic
115)]
116#![allow(clippy::module_name_repetitions)]
117
118mod palette;
119mod theme;
120
121pub use palette::ThemePalette;
122pub use theme::{Theme, ThemeName};
123
124/// Re-export ratatui's [`Color`] type for convenience.
125///
126/// This allows you to use `ratatui_themes::Color` without adding ratatui
127/// as a direct dependency just for the `Color` type.
128pub use ratatui::style::Color;
129
130/// Re-export ratatui's [`Style`] type for convenience.
131///
132/// This allows you to use `ratatui_themes::Style` without additional imports.
133pub use ratatui::style::Style;
134
135/// Enable included widgets.
136#[cfg(feature = "widgets")]
137pub mod widgets;
138
139#[cfg(feature = "widgets")]
140pub use widgets::ThemePicker;