ExRatatui.Widgets.Table (ExRatatui v0.7.1)

Copy Markdown View Source

A table widget with headers, rows, and optional selection.

Fields

  • :rows - list of rows, each row is a list of cell strings
  • :header - optional list of header cell strings
  • :widths - list of constraint tuples for column widths (e.g., [{:length, 10}, {:percentage, 50}, {:min, 5}])
  • :style - %ExRatatui.Style{} for the table
  • :block - optional %ExRatatui.Widgets.Block{} container
  • :highlight_style - %ExRatatui.Style{} for the selected row
  • :highlight_symbol - string prefix for the selected row
  • :selected - zero-based index of the selected row, or nil
  • :column_spacing - spacing between columns (default: 1)

Examples

iex> %ExRatatui.Widgets.Table{
...>   rows: [["Alice", "30"], ["Bob", "25"]],
...>   header: ["Name", "Age"],
...>   widths: [{:length, 15}, {:length, 10}]
...> }
%ExRatatui.Widgets.Table{
  rows: [["Alice", "30"], ["Bob", "25"]],
  header: ["Name", "Age"],
  widths: [length: 15, length: 10],
  style: %ExRatatui.Style{},
  block: nil,
  highlight_style: %ExRatatui.Style{},
  highlight_symbol: nil,
  selected: nil,
  column_spacing: 1
}

Summary

Types

t()

@type t() :: %ExRatatui.Widgets.Table{
  block: ExRatatui.Widgets.Block.t() | nil,
  column_spacing: non_neg_integer(),
  header: [String.t()] | nil,
  highlight_style: ExRatatui.Style.t(),
  highlight_symbol: String.t() | nil,
  rows: [[String.t()]],
  selected: non_neg_integer() | nil,
  style: ExRatatui.Style.t(),
  widths: [ExRatatui.Layout.constraint()]
}