Skip to content
UrushiDocumentation

Themes

A Theme names appearance by meaning rather than by component or renderer. Semantic tokens supply colors, while ComponentTheme supplies canonical styles and presentations for panels, lists, tables, trees, and scrollbars.

Run the complete Theme quickstart ↓

From meaning to terminal appearance

Themes preserve semantic intent while the active renderer decides which capabilities it can express.

  1. dataSemantic roleaccent, success, warning, error
  2. theme
    processThemeSelects tokens and component presentations
  3. style
    dataConcrete StyleColors and attributes
  4. render
    actorRendererExpresses the supported capabilities

accent, success, warning, and error remain stable application choices even when the final colors differ between light and dark backgrounds.

A Theme also owns canonical component presentations. theme.table(&table), for example, binds Table data to the Theme’s border, spacing, and role styles and returns a View.

Themes do not inspect the terminal. ThemeMode expresses a selection policy; the application supplies an optional observed terminal background. This keeps terminal I/O in the surface that owns the session. The same Theme can style static CLI output, prompts, Urushi TUI frames, and Views rendered into Ratatui without forcing those surfaces to share control flow.

Terminal window
cargo new theme-demo
cd theme-demo
cargo add urushi

Replace src/main.rs with:

use std::io;
use urushi::{ComponentRole, Table, ThemePreset, View};
fn main() -> io::Result<()> {
let theme = ThemePreset::get("Catppuccin Mocha")
.expect("built-in theme")
.theme();
let heading = View::text(
"Build status",
theme.text_style(ComponentRole::Accent),
);
let table = Table::text()
.headers(["Target", "State"])
.row(["release", "ready"]);
let view = View::column(
urushi::Align::Left,
[heading, theme.table(&table)],
);
urushi::println_view(&view)
}

Rendered output

Build status
┌─────────┬───────┐
│ Target  │ State │
├─────────┼───────┤
│ release │ ready │
└─────────┴───────┘

Run it with cargo run. The preset supplies semantic tokens and complete component presentations. The code asks for meaning (Accent, canonical Table) rather than choosing concrete colors and border styles at each call site.