gilt
Rich terminal formatting for Rust -- a port of Python's rich library.
gilt brings beautiful terminal output to Rust with styles, tables, trees, syntax highlighting, progress bars, and more -- all rendered as ANSI escape sequences.
Quick Start
[]
= "0.5"
use *;
v0.5.0 Highlights
- 7 derive macros --
#[derive(Table, Panel, Tree, Columns, Rule, Inspect, Renderable)] - Sparkline -- inline Unicode bar charts (
▁▂▃▄▅▆▇█) - Canvas -- Braille dot-matrix drawing (lines, rects, circles)
- Diff -- LCS-based unified and side-by-side text diffs
- Figlet -- large ASCII art text with built-in 5×7 block font
- CsvTable -- CSV-to-Table with built-in parser and optional
csvcrate - 73 examples covering all features
Features
Core Widgets
- Text -- Rich text with markup, styles, wrapping, alignment
- Table -- Unicode box-drawing tables with column alignment and row striping
- Panel -- Bordered content panels with titles
- Tree -- Hierarchical tree display with guide lines
- Columns -- Multi-column layout
- Layout -- Flexible split-pane layouts
Terminal Features
- Syntax -- Code highlighting via syntect (150+ languages)
- Markdown -- Terminal-rendered Markdown
- JSON -- Pretty-printed JSON with highlighting
- Progress -- Multi-bar progress display with ETA, speed, spinner
- Live -- Live-updating terminal display
- Status -- Spinner with status message
Rust-Native Extensions
- Gradients -- True-color RGB gradient text
- Sparkline -- Inline Unicode bar charts
- Canvas -- Braille dot-matrix drawing with line, rect, circle primitives
- Diff -- Unified and side-by-side text diffs with colored output
- Figlet -- Large ASCII art text rendering
- CsvTable -- CSV to rich Table conversion
- Stylize trait --
"hello".bold().red()method chaining - Iterator progress --
iter.progress()adapter #[derive(Table, Panel, Tree, Columns, Rule, Inspect, Renderable)]-- Auto-generate widgets from structs- Environment detection --
NO_COLOR,FORCE_COLOR,CLICOLORsupport - Inspect -- Debug any value with rich formatting
- Accessibility -- WCAG 2.1 contrast checking,
REDUCE_MOTIONdetection - Extended underlines -- Curly, dotted, dashed, double styles with color
- anstyle interop -- Bidirectional conversion with
anstyletypes
Integrations
- miette -- Diagnostic reporting with gilt styling
- eyre -- Error reporting with gilt styling
- tracing -- Log subscriber with colored output
- anstyle -- Convert between gilt and anstyle
Color/Styletypes
Feature Gates
All four heavy dependencies are default-on. Disable them for minimal builds:
# Full (default) -- includes json, markdown, syntax, interactive
= "0.5"
# Minimal -- no heavy deps
= { = "0.5", = false }
# Pick what you need
= { = "0.5", = false, = ["json", "syntax"] }
| Feature | Default | Description |
|---|---|---|
json |
yes | Pretty-printed JSON (serde, serde_json) |
markdown |
yes | Terminal Markdown rendering (pulldown-cmark) |
syntax |
yes | Syntax highlighting (syntect) |
interactive |
yes | Password prompts, select/multi-select (rpassword) |
tracing |
no | tracing subscriber with gilt formatting |
derive |
no | #[derive(Table, Panel, Tree, ...)] proc macros (7 derives) |
miette |
no | miette::ReportHandler implementation |
eyre |
no | eyre::EyreHandler implementation |
csv |
no | CSV file reading via csv crate (built-in parser always available) |
anstyle |
no | Bidirectional From conversions with anstyle types |
Examples
# Showcase (runs all major widgets)
# Core widgets
# Rust-native features
# Feature-gated examples
See the examples/ directory for all 73 examples.
Global Console
// Print with markup
print_text;
// Print JSON
print_json;
// Inspect any Debug value
inspect;
Performance
gilt includes a criterion benchmark suite (64 benchmarks) covering text rendering, style application, table layout, segment operations, and more:
Minimum Supported Rust Version
gilt requires Rust 1.82.0 or later (for std::sync::LazyLock).
License
MIT