rich-rs
Rich text and beautiful formatting for the terminal: a Rust port of Python's Rich library.
rich-rs focuses on expressive terminal output with a small, composable API. It supports tables, progress bars, Markdown, syntax highlighting, tracebacks, and more without extra setup.
Compatibility
rich-rs works on Linux, macOS, and Windows. True color / emoji works with modern terminals; legacy Windows console is limited to 16 colors.
Minimum Supported Rust Version: 1.85+ (Rust 2024 edition)
Installing
Add to your Cargo.toml:
[]
= "1.0.2"
Run the demo to see rich-rs in action:
Console Printing
To add rich output to your application, create a Console and use its print methods:
use ;
let mut console = new;
let text = from_markup.unwrap;
console.print.unwrap;
rich-rs will automatically word-wrap text to fit the terminal width and detect color support.
Markup
rich-rs uses a BBCode-like markup syntax for inline styling:
use ;
let mut console = new;
console.print.unwrap;
console.print.unwrap;
console.print.unwrap;
rich-rs Library
rich-rs ships with a set of built-in renderables you can combine to produce clean, beautiful CLI output.
Click the headings below for details:
rich-rs can render flexible tables with unicode box characters, borders, styles, and cell alignment.
use ;
let mut console = new;
let mut table = new;
table.add_column;
table.add_column;
table.add_column;
table.add_row_strs;
table.add_row_strs;
table.add_row_strs;
console.print.unwrap;
Tables automatically resize columns to fit the terminal width, wrapping text as needed.
rich-rs can render multiple flicker-free progress bars to track long-running tasks.
use ;
// Simple iterator progress
for item in .progress
For more control, create a Progress instance with custom columns:
use Progress;
let progress = new;
let task = progress.add_task;
// ... update task progress
Built-in columns include percentage, file size, transfer speed, time elapsed, and time remaining.
rich-rs can update content in-place for real-time displays.
use ;
use Duration;
let console = new;
let mut live = new;
live.start.unwrap;
for i in 0..10
live.stop.unwrap;
Live display supports transient mode (clears on exit), alt-screen mode, and vertical overflow handling.
rich-rs uses syntect to implement syntax highlighting with multiple themes.
use ;
let mut console = new;
let code = r#"fn main() {
let greeting = "Hello, World!";
println!("{}", greeting);
}
"#;
let syntax = new
.with_line_numbers
.with_theme;
console.print.unwrap;
Available themes include base16-ocean.dark, Solarized (dark), InspiredGitHub, and more.
rich-rs can render markdown with syntax-highlighted code blocks.
use ;
let mut console = new;
let md = r#"# Hello World
This is **bold** and *italic*.
- Item one
- Item two
```rust
fn main() {
println!("Hello!");
}
"#;
let markdown = Markdown::new(md); console.print(&markdown, None, None, None, false, "\n").unwrap();

Supports CommonMark + GitHub Flavored Markdown including tables, task lists, and fenced code blocks.
</details>
<details>
<summary>Trees</summary>
rich-rs can render hierarchical data with guide lines.
```rust
use rich_rs::{Console, Tree, Text, Style, SimpleColor};
let mut console = Console::new();
let mut tree = Tree::new(Box::new(Text::from_markup("[bold]:open_file_folder: Project[/]", true).unwrap()));
let src = tree.add(Box::new(Text::from_markup("[blue]:open_file_folder: src[/]", true).unwrap()));
src.add(Box::new(Text::from_markup("[green]:page_facing_up: main.rs[/]", true).unwrap()));
src.add(Box::new(Text::from_markup("[green]:page_facing_up: lib.rs[/]", true).unwrap()));
tree.add(Box::new(Text::from_markup("[yellow]:page_facing_up: Cargo.toml[/]", true).unwrap()));
console.print(&tree, None, None, None, false, "\n").unwrap();
rich-rs can render content in bordered boxes with titles.
use ;
use r#boxROUNDED;
let mut console = new;
let content = from_markup.unwrap;
let panel = new
.with_title
.with_box
.with_border_style;
console.print.unwrap;
rich-rs can render beautiful panic backtraces with syntax-highlighted source context.
use traceback;
// Install as the default panic handler
install;
// Now panics will show beautiful tracebacks
Tracebacks show the call stack with source code snippets and local variable values.
rich-rs can pretty-print data structures with syntax highlighting.
use ;
let mut console = new;
let data = r#"{"name": "rich-rs", "version": "1.0.0", "features": ["tables", "syntax"]}"#;
let pretty = from_str.with_indent_guides;
console.print.unwrap;
rich-rs provides interactive prompts with validation and choices.
use ;
// Text prompt with choices
let color = new
.with_choices
.run?;
// Numeric input
let age: i64 = ask?;
// Yes/No confirmation
if ask?
Supports password input, default values, and custom validation.
rich-rs can render content in neat columns with equal or optimal width.
use ;
let mut console = new;
let items: =
.map
.collect;
let columns = new.with_equal;
console.print.unwrap;
Acknowledgments
- Textualize for creating the original Python Rich library
- syntect for syntax highlighting
- crossterm for cross-platform terminal support
- pulldown-cmark for Markdown parsing
License
MIT License — see LICENSE for details.