Type Table

type Table struct {
	// contains filtered or unexported fields
}

Table incrementally paints headers and rows. It draws no outer surface or border, like shadcn's Table: wrap it in a Card or a bordered container for that. Columns are borrowed only while a Header or Row call is executing.

Constructors

BeginTable#

func BeginTable(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect, columns []TableColumn) Table

BeginTable starts a table whose first painted row is at bounds.Y. Cells have px-2 of horizontal padding. A cell whose text is wider than its column ends in an ellipsis, as it does in a native table; shadcn's cells never truncate, its auto-width columns grow with their content instead, which FitTableHeadings does for the headings of fixed-width columns.

Methods

Caption#

func (table *Table) Caption(text string)

Caption paints the muted caption below the rows already emitted.

Header#

func (table *Table) Header(cells []string)

Header paints a muted header row. Extra cells are ignored and absent cells remain blank.

HeaderHeight#

func (table Table) HeaderHeight(height float32) Table

HeaderHeight overrides the default header row height for subsequent calls.

Row#

func (table *Table) Row(id ui.ID, cells []string, selected bool)

Row paints one body row. A non-zero ID makes the row interactive; selected rows use the blue accent surface.

RowAt#

func (table *Table) RowAt(list ui.Scope, index int, cells []string, selected bool) bool

RowAt paints body row index of the list scope, numbering its own identity, and reports whether this paint is delivering a click on it. It is Row for a table whose rows are items of a list:

if table.RowAt(rows, i, cells[i], i == selected) { selected = i }

RowHeight#

func (table Table) RowHeight(height float32) Table

RowHeight overrides the default body and footer row height for subsequent calls.

RowLayout#

func (table *Table) RowLayout(id ui.ID, cells []string, state TableRowState, dst []ui.Rect) TableRowLayout

RowLayout paints one body row and appends its cell geometry to dst. The caller owns dst and may reuse it across rows to keep custom cell decoration allocation-free; a nil dst collects nothing.

RowState#

func (table *Table) RowState(id ui.ID, cells []string, state TableRowState)

RowState paints a body row with explicit selected/expanded state.