Skip to main content

Crate tiny_table

Crate tiny_table 

Source
Expand description

A terminal table renderer with column sizing, truncation, wrapping, and section separators.

The crate is designed around three core building blocks:

  • Table holds headers, rows, and the rendering configuration.
  • Column defines a header plus default styling for a column.
  • Cell lets 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

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;

Modules§

color
Color types and ANSI escape-code generation used by the styling API.
table
Table rendering primitives and formatting logic.