Table
April 28, 2026 · View on GitHub
Tabular data display with header, vertical/horizontal scrolling, and optional cell navigation. Implements values.Setter[TableProvider] so it works with values.Update.
Constructor: NewTable(id, class string, provider TableProvider, cellNav bool) *Table
cellNav enables column-by-column navigation in addition to row navigation.
Methods
Set(provider TableProvider)— replace the data source. Does not redraw; callRefresh()afterwards (orcore.Find(ui, id).Refresh())Refresh()— queue a redrawSelected() (row, col int)— currently highlighted row and column (column is meaningful only whencellNavis true)SetSelected(row, col int) bool— set the highlighted cell; returns true if the position is validOffset() (offsetX, offsetY int)— current scroll offsetSetOffset(offsetX, offsetY int)— set scroll positionSetCellStyler(fn func(row, col int, highlight bool) *Style)— per-cell style overrideCellBounds(row, col int) (x, y, w int, ok bool)— screen coordinates of a cell
Events
| Event | Data | Description |
|---|---|---|
"activate" | int, []string | Row activated via Enter; second arg is the full row data |
"select" | int, int | Selection changed (Space): row index and column index (-1 when not in cell-nav mode) |
Notes
Flags: "focusable", "grid" (toggle inner grid lines).
TableProvider:
type TableProvider interface {
Columns() []TableColumn // Header text + column width
Length() int // Row count
Str(row, col int) string // Cell content
}
Built-in: NewArrayTableProvider(headers []string, data [][]string) *ArrayTableProvider. Column widths are computed from the longest cell. For dynamic data sources (live cursors, paged APIs), implement TableProvider directly.
Important: unlike
List.Set,Table.Setupdates the provider but does not auto-refresh. Always followSet(orvalues.Update) with aRefresh()call on the table.