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.
See meaning survive presentation changes
Section titled “See meaning survive presentation changes”Run the complete Theme quickstart ↓
How themes preserve meaning
Section titled “How themes preserve meaning”Themes preserve semantic intent while the active renderer decides which capabilities it can express.
- dataSemantic roleaccent, success, warning, error
- themeprocessThemeSelects tokens and component presentations
- styledataConcrete StyleColors and attributes
- renderactorRendererExpresses 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.
Quickstart
Section titled “Quickstart”cargo new theme-democd theme-democargo add urushiReplace 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.