Skip to content

Grid Cell

A grid cell wraps one view inside a Grid and defines where it is placed and how it is styled. Rows and columns start at 1, and an end position is exclusive: a cell from ColStart(2) to ColEnd(4) covers columns 2 and 3. By default the content stretches over the whole cell; with another alignment the content wraps its size and the grid background shows around it.

Grid Cell

return Grid(
	GridCell(Text("rows 1-2, column 1")).
		RowStart(1).RowEnd(3).ColStart(1).ColEnd(2).
		BackgroundColor("#FDE2C4").Padding(Padding{}.All(L8)),
	GridCell(Text("row 1, columns 2-3")).
		RowStart(1).RowEnd(2).ColStart(2).ColEnd(4).
		BackgroundColor("#C9E7F8").Padding(Padding{}.All(L8)),
	GridCell(Text("Alignment(Center)")).
		RowStart(2).RowEnd(3).ColStart(2).ColEnd(4).
		Alignment(Center).
		BackgroundColor("#D8F0D2").Padding(Padding{}.All(L8)),
).Rows(2).
	Columns(3).
	Gap(L8).
	Heights(L80, L80).
	BackgroundColor(ColorCardBody).
	Frame(Frame{Width: L560})

Constructors

ConstructorDescription
GridCell(body core.View) TGridCellCreates a new grid cell containing the given body view.

Methods

MethodDescription
Alignment(a Alignment) TGridCellSets the alignment of the content within the grid cell.
BackgroundColor(color Color) TGridCellSets the background color of the grid cell.
ColEnd(colEnd int) TGridCellSets the exclusive end column; it must be at least ColStart+1.
ColSpan(colSpan int) TGridCellSpans the given number of columns; convenient, but may behave unexpectedly when cells overlap.
ColStart(colStart int) TGridCellSets the start column, starting at 1.
Padding(p Padding) TGridCellSets the inner spacing around the cell content.
RowEnd(rowEnd int) TGridCellSets the exclusive end row; it must be at least RowStart+1.
RowSpan(rowSpan int) TGridCellSpans the given number of rows; convenient, but may behave unexpectedly when cells overlap.
RowStart(rowStart int) TGridCellSets the start row, starting at 1.

Related