Tca-Ratatui
Ratatui integration for TCA themes. Loads and resolves TCA theme files into ratatui::style::Color values ready to use in widgets and styles.
Installation
Loading a single theme
By name, slug, or file path
use TcaTheme;
// Theme name or slug — checks user themes, then built-ins
let theme = new;
let theme = new;
let theme = new; // flexible slug matching
// Exact file path
let theme = new;
// Auto-detect from terminal dark/light mode, then fall back to built-in default
let theme = new;
let theme = default; // same as new(None)
From a TOML string
use TcaTheme;
let theme = try_from.expect;
From a tca_types::Theme
use TcaTheme;
use BuiltinTheme;
let raw = Nord.theme;
let theme = try_from?;
Programmatically with TcaThemeBuilder
use ;
use Color;
let theme = new
.semantic
.ui
.build;
Loading a collection of themes
use TcaThemeCursor;
// All built-in themes
let mut cursor = with_builtins;
// User-installed themes from XDG data dir
let mut cursor = with_user_themes;
// Built-ins merged with user themes (user overrides on name match)
let mut cursor = with_all_themes;
// From an explicit list
let mut cursor = new;
If you need the raw tca_types::Theme type instead, the generic ThemeCursor<T> is also re-exported:
use ThemeCursor;
use Theme;
let mut cursor: = with_builtins;
Theme cursor navigation
use ;
let mut cursor = with_builtins;
// Current theme without moving
let theme: &TcaTheme = cursor.peek.unwrap;
// Advance (wraps at end)
let theme: &TcaTheme = cursor.next.unwrap;
// Retreat (wraps at start)
let theme: &TcaTheme = cursor.prev.unwrap;
// Inspect without moving
println!;
println!;
// Iterate all themes without cycling
for theme in cursor.themes
Using theme colors
use Style;
let normal = default.fg.bg;
let secondary = default.fg;
let muted = default.fg;
let border = default.fg;
let selection = default.bg.fg;
let error = default.fg;
let warning = default.fg;
let ansi_red = default.fg;
// Palette ramps (if the theme defines them)
if let Some = theme.palette.get_ramp
TcaTheme fallback behavior
TcaTheme::new() resolution order:
- User theme files —
~/.local/share/tca/themes/<name>.toml, or an exact file path - Built-in themes — always available, no installation required
- Auto-detect — dark or light built-in based on the terminal's background color
If semantic or ui color references can't be resolved, they fall back to sensible ratatui named colors (e.g. Color::Red for semantic.error).
Built-in themes
| Slug | Style |
|---|---|
catppuccin-mocha |
dark |
cyberpunk |
dark |
dracula |
dark |
everforest-dark |
dark |
gruvbox-dark |
dark |
mono |
dark |
nord |
dark |
one-dark |
dark |
rose-pine |
dark |
solarized-light |
light |
tokyo-night |
dark |
Color sections
TcaTheme
├── meta — name, slug, author, version, description, dark
├── ansi — 16 ANSI colors (black, red, … bright_white) as Color::Rgb
├── semantic — error, warning, info, success, highlight, link
├── ui — bg_primary/secondary, fg_primary/secondary/muted,
│ border_primary/muted, cursor_primary/muted,
│ selection_bg/fg
├── palette — named color ramps (e.g. neutral.0–7, red.0–2)
└── base16 — base00–base0F if the theme defines them
Features
| Feature | Default | Description |
|---|---|---|
fs |
enabled | File I/O, TcaTheme::new(), TcaThemeCursor, TOML parsing |
widgets |
enabled | ColorPicker widget |
# Builder-only, no file I/O or widgets
= { = "0.4", = false }
# With widgets only
= { = "0.4", = ["widgets"] }
Examples
# Interactive theme browser (cycles through all themes)
# Browse themes from a directory
# Browse built-ins only
License
MIT