Quickstart
This tutorial builds a small status panel and writes it to stdout. It uses no raw mode and starts no event loop.
1. Add Urushi
Section titled “1. Add Urushi”cargo add urushi2. Build a view
Section titled “2. Build a view”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.
3. Write the view
Section titled “3. Write the view”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:
cargo runThe 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.
4. Check redirected output
Section titled “4. Check redirected output”cargo run > 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.