# `ExRatatui.Widgets.Table`
[🔗](https://github.com/mcass19/ex_ratatui/blob/v0.10.1/lib/ex_ratatui/widgets/table.ex#L1)

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

## Fields

  * `:rows` - list of rows. Each row is a list of cells, and each cell
    accepts any `ExRatatui.Text`-coercible line-like value: a `String.t()`,
    a `%ExRatatui.Text.Span{}`, a `%ExRatatui.Text.Line{}`, or a list of
    spans. Cells are single-line — strings with embedded newlines raise.
  * `:header` - optional list of header cells (same shape as row cells)
  * `:footer` - optional list of footer cells (same shape as row cells).
    Renders at the bottom of the table area.
  * `: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 (row-level highlight)
  * `:column_highlight_style` - `%ExRatatui.Style{}` for the selected
    column. `nil` means no column highlight.
  * `:cell_highlight_style` - `%ExRatatui.Style{}` for the selected
    cell (intersection of selected row + selected column). `nil` means
    no per-cell highlight.
  * `:header_style` - `%ExRatatui.Style{}` applied to the header row.
    `nil` falls back to the table's `:style`.
  * `:footer_style` - `%ExRatatui.Style{}` applied to the footer row.
    `nil` falls back to the table's `:style`.
  * `:highlight_symbol` - string prefix for the selected row
  * `:highlight_spacing` - when to reserve the highlight symbol
    column. One of `:always`, `:when_selected` (default — matches
    ratatui), or `:never`.
  * `:selected` - zero-based index of the selected row, or `nil`. Must be in
    `0..length(rows) - 1`; any other value raises `ArgumentError` at render time.
  * `:selected_column` - zero-based index of the selected column, or
    `nil`. Required to activate `:column_highlight_style` and
    `:cell_highlight_style` — without it, the column / cell styles
    never fire (ratatui's `TableState::select_column/1` is the
    gating mechanism). Must be in `0..widths_count - 1`.
  * `: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"],
      footer: nil,
      widths: [length: 15, length: 10],
      style: %ExRatatui.Style{},
      block: nil,
      highlight_style: %ExRatatui.Style{},
      column_highlight_style: nil,
      cell_highlight_style: nil,
      header_style: nil,
      footer_style: nil,
      highlight_symbol: nil,
      highlight_spacing: :when_selected,
      selected: nil,
      selected_column: nil,
      column_spacing: 1
    }

# `cell`

```elixir
@type cell() ::
  String.t()
  | ExRatatui.Text.Span.t()
  | ExRatatui.Text.Line.t()
  | [ExRatatui.Text.Span.t()]
```

# `highlight_spacing`

```elixir
@type highlight_spacing() :: :always | :when_selected | :never
```

# `t`

```elixir
@type t() :: %ExRatatui.Widgets.Table{
  block: ExRatatui.Widgets.Block.t() | nil,
  cell_highlight_style: ExRatatui.Style.t() | nil,
  column_highlight_style: ExRatatui.Style.t() | nil,
  column_spacing: non_neg_integer(),
  footer: [cell()] | nil,
  footer_style: ExRatatui.Style.t() | nil,
  header: [cell()] | nil,
  header_style: ExRatatui.Style.t() | nil,
  highlight_spacing: highlight_spacing(),
  highlight_style: ExRatatui.Style.t(),
  highlight_symbol: String.t() | nil,
  rows: [[cell()]],
  selected: non_neg_integer() | nil,
  selected_column: non_neg_integer() | nil,
  style: ExRatatui.Style.t(),
  widths: [ExRatatui.Layout.constraint()]
}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
