Skip to content
UrushiDocumentation

Styles

Use Styles when the question is how terminal cells look:

  • foreground and background color;
  • bold, dim, italic, blinking, reverse, hidden, and strikethrough attributes;
  • underline shape and color; and
  • OSC 8 hyperlinks.

Styles do not decide where content goes or how much space it receives. Go to Layout for margin, borders, padding, dimensions, alignment, rows, columns, grids, and viewports. The layout API includes a type named BlockStyle, but its geometry belongs under Layout in this documentation because that is the task it solves.

Use Themes when appearance expresses application meaning such as success, warning, selected, or focused.

Run the complete Styles quickstart ↓

Create a project and install Urushi:

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

Replace src/main.rs with:

use std::io;
use urushi::{Color, StyledText, TextStyle};
fn main() -> io::Result<()> {
let text = StyledText::new(
"ready",
TextStyle::new().foreground(Color::GREEN).bold(),
);
urushi::println(&text)
}

Run it with cargo run:

Rendered output

ready

TextStyle travels with the text instead of writing raw ANSI into the string. The renderer keeps the content usable when a terminal or redirected stream does not support a requested capability.