Skip to main content

Table

Tabular data renderer with fixed or auto-sized columns, header row, and selection highlight.

Usage

const cols = [_]tui.widgets.Column{
.{ .header = "Name" },
.{ .header = "CPU", .width = 6 },
.{ .header = "Mem", .width = 8 },
};

const rows = [_]tui.widgets.Row{
.{ .cells = &.{ "zig", "12%", "156 MB" } },
.{ .cells = &.{ "chrome", "15%", "2048 MB" } },
};

tui.widgets.Table{
.columns = &cols,
.rows = &rows,
.header_style = .{ .fg = .cyan, .modifier = .{ .bold = true } },
.selected_style = .{ .fg = .black, .bg = .cyan },
.selected = 0,
}.render(area, buf);

Column sizing

  • Set .width on a Column for a fixed pixel width.
  • Leave .width = null to let the column auto-size based on content.

Fields

FieldTypeDescription
columns[]const ColumnColumn headers and widths
rows[]const RowData rows
header_styleStyleStyle applied to the header row
selected_styleStyleStyle applied to the selected row
selected?usizeIndex of the highlighted row