Skip to main content

Module renderables

Module renderables 

Source
Expand description

Renderable components for rich terminal output.

This module provides high-level components for structured terminal output:

  • Table: Display data in rows and columns with borders
  • Panel: Frame content with a title and border
  • Tree: Hierarchical data with guide lines
  • ProgressBar / Spinner: Visual progress indicators
  • Rule: Horizontal divider lines
  • Columns: Multi-column text layout
  • Align: Text alignment utilities
  • Emoji: Single emoji renderable (Rich-style)
  • Group: Combine multiple renderables into one

§Examples

§Tables

use rich_rust::prelude::*;

let table = Table::new()
    .title("Users")
    .add_column(Column::new("Name").style(Style::new().bold()))
    .add_column(Column::new("Email"))
    .add_row(Row::new().cell("Alice").cell("alice@example.com"))
    .add_row(Row::new().cell("Bob").cell("bob@example.com"));

// Render to segments
for segment in table.render(80) {
    print!("{}", segment.text);
}

§Panels

use rich_rust::prelude::*;

let panel = Panel::new("Important message!")
    .title("Notice")
    .border_style(Style::new().color(Color::parse("yellow").unwrap()));

for segment in panel.render(60) {
    print!("{}", segment.text);
}

§Trees

use rich_rust::prelude::*;

let tree = Tree::new(
    TreeNode::new("Root")
        .child(TreeNode::new("Branch A")
            .child(TreeNode::new("Leaf 1")))
        .child(TreeNode::new("Branch B")),
)
.guides(TreeGuides::Unicode);

for segment in tree.render() {
    print!("{}", segment.text);
}

§Rules (Dividers)

use rich_rust::prelude::*;

let rule = Rule::new()
    .style(Style::new().color(Color::parse("blue").unwrap()));

let titled_rule = Rule::with_title("Section Title");

for segment in rule.render(80) {
    print!("{}", segment.text);
}

§Optional Features

Additional renderables are available with feature flags:

  • syntax: [Syntax] - Syntax-highlighted source code
  • markdown: [Markdown] - Markdown document rendering
  • json: [Json] - JSON formatting with syntax highlighting

Re-exports§

pub use align::Align;
pub use align::AlignLines;
pub use align::AlignMethod;
pub use align::VerticalAlignMethod;
pub use align::align_text;
pub use columns::Columns;
pub use constrain::Constrain;
pub use control::Control;
pub use emoji::Emoji;
pub use emoji::NoEmoji;
pub use group::Group;
pub use group::group;
pub use layout::Layout;
pub use layout::LayoutSplitter;
pub use layout::Region;
pub use padding::Padding;
pub use padding::PaddingDimensions;
pub use panel::Panel;
pub use pretty::Inspect;
pub use pretty::InspectOptions;
pub use pretty::Pretty;
pub use pretty::PrettyOptions;
pub use pretty::inspect;
pub use progress::BarStyle;
pub use progress::DownloadColumn;
pub use progress::FileSizeColumn;
pub use progress::ProgressBar;
pub use progress::Spinner;
pub use progress::TotalFileSizeColumn;
pub use progress::TransferSpeedColumn;
pub use rule::Rule;
pub use table::Cell;
pub use table::Column;
pub use table::Row;
pub use table::Table;
pub use table::VerticalAlign;
pub use traceback::Traceback;
pub use traceback::TracebackFrame;
pub use traceback::print_exception;
pub use tree::Tree;
pub use tree::TreeGuides;
pub use tree::TreeNode;

Modules§

align
Align - Horizontal alignment wrapper for renderables.
columns
Columns - Arrange items in multiple columns.
constrain
Constrain - limit the width of a renderable (Python Rich rich.constrain parity).
control
Control renderable (Python Rich rich.control parity).
emoji
group
Group renderable for combining multiple renderables.
layout
Layout - split the terminal into rows/columns with nested regions.
padding
Padding - CSS-style padding for renderables.
panel
Panel - bordered box containing content.
pretty
Pretty printing / inspection helpers.
progress
Progress bar renderable.
rule
Rule - horizontal line with optional title.
table
Table - structured data display with columns and rows.
traceback
Traceback rendering.
tree
Tree renderable.

Traits§

Renderable
Trait for objects that can be rendered to the console.