Expand description
A terminal table renderer with column sizing, truncation, wrapping, and section separators.
The crate is designed around three core building blocks:
Tableholds headers, rows, and the rendering configuration.Columndefines a header plus default styling for a column.Celllets you override styling or truncation on individual values.
§Quick Start
use tiny_table::{Cell, Column, Align, Table, Trunc};
let mut table = Table::with_columns(vec![
Column::new("Name").width(0.30),
Column::new("Role").truncate(Trunc::Middle),
Column::new("Status"),
]);
table.add_section("Team").align(Align::Left);
table.add_row(vec![
Cell::new("Ada Lovelace"),
Cell::new("Principal Engineer"),
Cell::new("Active").bright_green().bold(),
]);
let rendered = table.render();
assert!(rendered.contains("Name"));
assert!(rendered.contains("Ada Lovelace"));§How It Fits Together
- Use
Table::with_columnswhen you already know the schema. - Use
Table::add_rowto append values. - Use
Table::columnto tweak one column by index or header text. - Use
Table::add_sectionorTable::add_separatorto break the table into visual groups. - Use
Table::renderwhen you want the formatted string, orTable::printwhen you just want to write it to standard output.
When a terminal width is available, fractional columns are distributed across the remaining content width after fixed and content-based columns are resolved.
Re-exports§
pub use color::CustomColor;pub use table::Align;pub use table::Cell;pub use table::Color;pub use table::Column;pub use table::ColumnTarget;pub use table::ColumnWidth;pub use table::SectionStyle;pub use table::Table;pub use table::TableStyle;pub use table::Trunc;