Skip to content

Table Column

A table column defines the header cell of one column of a Table and the column width. Its alignment, background, padding and border apply to the header cell; style the body cells with TableCell. A column action is typically used for sorting.

Table

return Table(
	TableColumn(Text("Name")),
	TableColumn(Text("Role")).Width(L160),
	TableColumn(Text("Status")).Alignment(Trailing),
).Rows(
	TableRow(
		TableCell(Text("Ada")),
		TableCell(Text("Admin")),
		TableCell(Text("active")),
	),
	TableRow(
		TableCell(Text("Linus")),
		TableCell(Text("Editor")),
		TableCell(Text("invited")).BackgroundColor("#FDE2C4"),
	).HoveredBackgroundColor(ColorCardFooter),
	TableRow(
		TableCell(Text("Grace: ColSpan(2)")).ColSpan(2),
		TableCell(Text("active")),
	).BackgroundColor("#C9E7F8"),
).Frame(Frame{Width: L560})

Constructors

ConstructorDescription
TableColumn(content core.View) TTableColumnCreates a new table column with the given header content.

Methods

MethodDescription
Action(action func()) TTableColumnSets an optional click/tap action for the column’s header cell.
Alignment(alignment Alignment) TTableColumnSets the content alignment within the column cell.
BackgroundColor(backgroundColor Color) TTableColumnSets the background color for the column cell.
Border(border Border) TTableColumnSets the border for the column cell.
Content(content core.View) TTableColumnReplaces the header content.
HoveredBackgroundColor(backgroundColor Color) TTableColumnSets the background color when the column cell is hovered.
Key(name, id string) TTableColumnIdentifies the action across renders by what it acts on, e.g. (“sort”, column).
Padding(padding Padding) TTableColumnSets the padding for the column cell.
Span(span int) TTableColumnSets how many columns this header should span.
Width(width Length) TTableColumnSets the column width.

Related