Expand description
Macro wrapper over tabled crate, allowing to create tables inplace or from Vec<Vec<String>> treating first data row
both as data or as header overcoming specific cont trait treatment as originally in tabled.
§Features
- Automatic Column Spanning: Rows with fewer columns automatically span to fill the table
- Customizable Styling: Configure table style, header color, first column color, content color, border color, and bold headers
- Simple Macro Syntax: Create tables inline or from existing collections
- Extensible: Use the re-exported
tabledmodule for advanced customization
§Examples
§Basic Table with Literal Data
use lil_tabby::tabby;
let t = tabby![
{ style: ascii }
["Header 1", "Header 2", "Header 3"],
["Short", "Row"], // Auto-spans to fill remaining columns
["Full", "Width", "Row"]
];
println!("{}", t);Output:
+----------+----------+----------+
| Header 1 | Header 2 | Header 3 |
+----------+----------+----------+
| Short | Row | |
+----------+----------+----------+
| Full | Width | Row |
+----------+----------+----------+§Styled Table with Custom Options
use lil_tabby::tabby;
let t = tabby![
{ style: modern_rounded, header: green, labels: yellow, color: blue, border: red, bold: true }
["Header 1", "Header 2", "Header 3"],
["Short", "Row"],
["Full", "Width", "Row"]
];
println!("{}", t);§Table from Vec<Vec<String>>
use lil_tabby::tabby;
let data: Vec<Vec<String>> = vec![
vec!["Header 1".to_string(), "Header 2".to_string(), "Header 3".to_string()],
vec!["Row 1".to_string()],
vec!["Row 2 Col 1".to_string(), "Row 2 Col 2".to_string()]
];
let t = tabby!(data);
println!("{}", t);§Post-Creation
Just re-export tabled
use lil_tabby::{tabby, tabled};
let mut table = tabby![
{ style: ascii_rounded, border: bright_green }
["a", "b", "c"],
["c", "d"],
["e"]
];
table.modify(tabled::settings::object::Columns::new(0..), tabled::settings::Alignment::right());
println!("{}", table);Output:
+---+---+---+
| a | b | c |
+---+---+---+
| d | e |
+---+-------+
| f |
+-----------+§Styling Options
The tabby! macro accepts an optional styling block with these parameters:
style: Table style (e.g.,modern_rounded,ascii_rounded,markdown). Defaults tomodern_rounded. Maps totabled::settings::Styleheader: First row color (e.g.,green,blue,red). Defaults towhite. All colors mapped totabled::settings::Color::FG_<COLOR>labels: First column color (e.g.,yellow,cyan). Defaults towhitecolor: Content color (e.g.,blue,magenta). Defaults towhiteborder: Border color (e.g.,red,bright_green). Defaults tobright_blackbold: Whether the header row is bold (trueorfalse). Defaults tofalse
§Limitations
- Table limited to 20 columns, due to const trait implementation, each used size should be covered. So, 20 like 640kb, enough, anyway wont fit the screen.
Modules§
- paste
pastere-export for color identifiers- tabled
- Re-exported
tabledcrate for advanced table customization
Macros§
- tabby
- Main macro