richrs
A Rust port of the Rich Python library for beautiful terminal output.
Overview
richrs brings the power of Python's Rich library to Rust, providing beautiful terminal output with colors, styles, tables, progress bars, and more. The API is designed to feel Rust-native while maintaining pixel-perfect compatibility with Python Rich output.
use *;
Features
| Feature | Description |
|---|---|
| Console | Main interface for terminal output with markup support |
| Style | Text styles with colors and attributes (bold, italic, underline, etc.) |
| Color | Full color support: ANSI 16 colors and 256-color palette |
| Text | Rich text objects with inline styling and spans |
| Markup | BBCode-like syntax: [bold red]text[/] |
| Panel | Boxed content with titles, subtitles, and multiple border styles |
| Table | Data tables with borders, alignment, and styling |
| Tree | Hierarchical data visualization with guides |
| Rule | Horizontal dividers with optional centered titles |
| Progress | Progress bars with multiple concurrent tasks |
| Spinner | 45+ animated loading indicators |
| Status | Spinner with status message for long-running operations |
| Prompt | User input with validation (text, confirm, int, float) |
| Columns | Multi-column layout for content |
| Live | Real-time content updates in place |
| Syntax | Syntax highlighting for 100+ languages (optional feature) |
| Markdown | Markdown rendering (optional feature) |
| Logging | Styled log handler with levels and timestamps |
| Pretty | Pretty-printing for data structures |
| Traceback | Formatted error tracebacks with context |
| Highlighter | Automatic pattern highlighting (URLs, numbers, UUIDs, etc.) |
| Emoji | 670+ emoji name-to-character mappings |
| Theme | Named style collections for consistent theming |
Installation
Add to your Cargo.toml:
[]
= "0.1"
Optional Features
[]
= { = "0.1", = ["syntax", "markdown"] }
| Feature | Description | Dependencies |
|---|---|---|
syntax |
Syntax highlighting for code | syntect |
markdown |
Markdown rendering | pulldown-cmark |
full |
Enable all optional features | - |
Quick Start
Text Styling
use *;
Panels
use *;
Tables
use *;
Trees
use *;
Progress Bars
use *;
Spinners
use *;
use thread;
use Duration;
Status (Spinner with Message)
use *;
use Duration;
Prompts
use *;
Syntax Highlighting
Requires the syntax feature.
use *;
Markdown
Requires the markdown feature.
use *;
Live Display
use *;
use Duration;
Pretty Printing
use *;
use HashMap;
Style Reference
Text Attributes
| Attribute | Description |
|---|---|
bold |
Bold text |
italic |
Italic text |
underline |
Underlined text |
strike |
Strikethrough |
dim |
Dimmed text |
reverse |
Swap foreground/background |
blink |
Blinking text |
conceal |
Hidden text |
Colors
Standard colors: black, red, green, yellow, blue, magenta, cyan, white
Bright variants: bright_red, bright_green, bright_blue, etc.
256-color palette: color(196)
Demo
Run the interactive demo to see all features in action:
Minimum Supported Rust Version
richrs requires Rust 1.85 or later.
Dependencies
Required
crossterm- Terminal capabilitiesunicode-width- Unicode text width calculationunicode-segmentation- Unicode grapheme handlingthiserror- Error handlingregex- Markup and pattern parsingonce_cell- Lazy initialization
Optional
syntect- Syntax highlighting (feature:syntax)pulldown-cmark- Markdown parsing (feature:markdown)
License
MIT License - see LICENSE for details.
Acknowledgments
- Textualize for the original Rich library
- The Rust community for excellent terminal libraries