Crates.io | fancy-table |
lib.rs | fancy-table |
version | 0.4.1 |
created_at | 2024-09-27 09:28:27.326116+00 |
updated_at | 2025-08-30 20:15:18.298879+00 |
description | Fancy tables with bells and whistles |
homepage | |
repository | https://github.com/mbuczko/fancy-table |
max_upload_size | |
id | 1388510 |
size | 64,929 |
The primary motivation behind this project was creating ASCII tables capable of displaying multi-line rows, particularly for content like JSON snippets. While numerous similar libraries exist, none properly handled this use case—which is what distinguishes Fancy Table from its competitors.
The project has evolved significantly, with several additional features implemented to create even more sophisticated tables:
[dependencies]
fancy-table = "0.4.1"
All crucial functionality exposed via simple, yet quite powerful API:
let mut table = FancyTable::create(FancyTableOpts {
charset: Charset::Modern,
..Default::default()
})
.add_title_with_align("props", TitleAlign::RightOffset(1))
.add_column_named("ID", Layout::Slim)
.add_column_named("NAME", Layout::Fixed(16))
.add_column_named_wrapping_with_align("CHARACTER", Layout::Fixed(11), Align::Center)
.add_column_named_with_align("BADNESS SCALE", Layout::Expandable(15), Align::Center)
.add_column_named_wrapping_with_align("DESCRIPTION", Layout::Expandable(150), Align::Right)
.padding(1)
.hseparator(Some(Separator::Double))
.rseparator(Some(Separator::Custom('┄')))
.build(80);
table.render(vec![
[
"1",
"Maeglin",
"Elf",
"Renegade\n10/10",
"Maeglin is an elf who betrayed his fellow elves to the evil Morgoth in an age before The Lord of the Rings.",
],
[
"29",
"Tauriel",
"Woodland elf",
"Tearjerker\n1/10",
"Tauriel is a woodland elf created for The Hobbit films. Her name means \"daughter of the forest\" in Sindarin.",
]
]);
results in fancy looking table with title and headers:
╭────┬────────────────┬───────────┬───────────────┬──────────────────▪ props ▪─╮
│ ID │ NAME │ CHARACTER │ BADNESS SCALE │ DESCRIPTION │
╞════╪════════════════╪═══════════╪═══════════════╪════════════════════════════╡
│ 1 │ Maeglin │ Elf │ Renegade │ Maeglin is an elf who │
│ │ │ │ 10/10 │ betrayed his fellow elves │
│ │ │ │ │ to the evil Morgoth in an │
├┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┤
│ 29 │ Tauriel │ Woodland │ Tearjerker │ Tauriel is a woodland elf │
│ │ │ elf │ 1/10 │ created for The Hobbit │
│ │ │ │ │ films. Her name means │
╰────┴────────────────┴───────────┴───────────────┴────────────────────────────╯
Fanciness disclaimer: depending on your terminal font quality of final result may range from unreadable piece of sh*t to beautiful looking table :)
To get some more idea how tables may look like, have a look at examples:
# available examples: colored, modern, classic, simple, minimal
cargo run --example modern