ratatui-widgettable
A Ratatui table widget whose cells can contain any widget, not just text.
Ratatui's built-in Table only supports Text in its cells. This crate provides a Table with the
same API and rendering behavior, where each Cell can hold a Paragraph (e.g. with wrapping), a
Block, a Gauge, a List, a Chart, another Table, or any other widget.

Installation
cargo add ratatui-widgettable
Usage
use Constraint;
use ;
use ;
let rows = ;
let widths = ;
let table = new
.header
.block;
Demo
Run the interactive demo shown above with cargo run --example demo. It shows a live task list
with wrapped paragraphs, gauges and sparklines in the cells:
| Key | Action |
|---|---|
↑/↓, j/k, g/G |
Select a row, or the first/last row |
←/→, h/l |
Select a column |
space |
Start or pause the selected task |
+/- |
Change the progress of the selected task |
enter |
Expand or collapse the selected row |
s |
Sort by the selected column (press again to reverse) |
a/d/r |
Add, delete, or reset a task |
p |
Cycle the scroll padding |
q |
Quit |
You can also scroll with the mouse, click a cell to select it, and click a header to sort by that
column. The mouse support is built with Cell::from_fn, which records where each cell was
rendered.
The animation is recorded with betamax using assets/record.sh.
Migrating from ratatui's Table
The API mirrors ratatui's Table, Row and Cell, and reuses ratatui's TableState and
HighlightSpacing, so your existing state handling keeps working. In most cases, you only need to
change your imports:
-use ratatui::widgets::{Cell, Row, Table, TableState};
+use ratatui::widgets::TableState;
+use ratatui_widgettable::{Cell, Row, Table};
Differences from ratatui's table:
Cell::newtakes a widget. To create a cell from a string, useCell::from("text")(anything that converts intoTextstill works withCell::fromandRow::new).Cell::from_fn(|area, buf| ...)creates a cell from a closure. Use it for widgets that only implementWidgetby value, stateful widgets, or custom drawing.Table,Row, andCelldo not implementClone,PartialEq,Eq, orHashbecause cells hold arbitrary widgets.- Includes
Table::scroll_padding, which isn't yet in a released version of ratatui. - The deprecated
Table::highlight_stylehas been left out. Userow_highlight_styleinstead.
As with the built-in table, a row's height is fixed (1 by default). Use Row::height to make room
for widgets that need more than one line. Widgets are rendered into the area of the cell and are
clipped to it.
Supported widgets
Cell::new accepts any W where &W: Widget. All of ratatui's built-in widgets implement
Widget for a reference, as do Text, Line, and Span. To support this in your own widgets,
implement Widget for &MyWidget.
Testing
Besides unit tests, the table is fuzzed against ratatui's own Table to check that text-only tables
render identically, and with random widget cells to check that nothing panics or draws outside the
table. See fuzz/README.md, and docs/fuzzing-findings.md
for the bugs it found.
Compatibility
- Ratatui 0.30 (
ratatui-core0.1 andratatui-widgets0.3) - Minimum supported Rust version: 1.88
no_stdcompatible (requiresalloc)
License
MIT. This crate is based on the Table widget from Ratatui, which is also MIT licensed. See
LICENSE.