Skip to content
UrushiDocumentation

Quickstart

This tutorial builds a small status panel and writes it to stdout. It uses no raw mode and starts no event loop.

Terminal window
cargo add urushi

Create a TextStyle for the message, wrap the text in a bordered BlockStyle, and compose both values into a View.

use urushi::{BlockStyle, Border, Color, TextStyle, View};
fn status_view() -> View {
let text = TextStyle::new()
.foreground(Color::GREEN)
.bold();
let panel = BlockStyle::new()
.border(Border::ROUNDED)
.border_foreground(Color::BRIGHT_BLACK)
.padding((0, 1));
View::block(panel, View::text("Build complete", text))
}

TextStyle describes inline appearance. BlockStyle describes geometry such as border and padding. View holds the renderer-neutral composition.

fn main() -> std::io::Result<()> {
urushi::println_view(&status_view())
}

println_view detects stdout, resolves the view against the terminal width, selects supported color and attribute features, writes it, and appends a newline.

Run the program:

Terminal window
cargo run

The program renders this panel. The preview preserves the requested green, bold message and bright-black border instead of flattening them into plain documentation text:

╭────────────────╮
│ Build complete │
╰────────────────╯

The exact appearance follows the terminal’s capabilities.

Terminal window
cargo run > result.txt
result.txt
╭────────────────╮
│ Build complete │
╰────────────────╯

When stdout is redirected, Urushi emits an unbounded plain-text representation. The border and padding remain because they are layout, but Urushi does not write ANSI styling into the file. NO_COLOR=1 cargo run removes color on a terminal while retaining supported non-color attributes.