Skip to main content

Crate ratatui_widgettable

Crate ratatui_widgettable 

Source
Expand description

A Ratatui table widget whose cells can contain any widget.

This crate provides a Table that works exactly like the Table widget built into Ratatui, except that each Cell can hold any widget (e.g. Paragraph, Block, Gauge, List, or even another Table) rather than only Text.

The API mirrors the built-in table, and it uses the same TableState and HighlightSpacing types, so switching over is usually just a matter of changing imports:

-use ratatui::widgets::{Cell, Row, Table, TableState};
+use ratatui::widgets::TableState;
+use ratatui_widgettable::{Cell, Row, Table};

§Example

use ratatui::layout::Constraint;
use ratatui::widgets::{Block, Gauge, Paragraph, Wrap};
use ratatui_widgettable::{Cell, Row, Table};

let rows = [Row::new(vec![
    Cell::from("Build"),
    Cell::new(
        Paragraph::new("Compiling a very long list of crates, this might take a while")
            .wrap(Wrap { trim: true }),
    ),
    Cell::new(Gauge::default().percent(42)),
])
.height(3)];
let widths = [
    Constraint::Length(8),
    Constraint::Fill(1),
    Constraint::Length(20),
];
let table = Table::new(rows, widths)
    .header(Row::new(vec!["Step", "Details", "Progress"]))
    .block(Block::bordered().title("Jobs"));

Structs§

Cell
A Cell contains the widget to be displayed in a Row of a Table.
Row
A single row of data to be displayed in a Table widget.
Table
A widget to display data in formatted columns, where each cell can contain any widget.
TableState
State of a Table widget

Enums§

HighlightSpacing
This option allows the user to configure the “highlight symbol” column width spacing