SimpleGrid
Responsive equal cells: give a minimum child width, get the right column count.
A lotusui extension. SimpleGrid derives its column count from the
available width (never below 1, never above maxCols) — resize the window and the
columns follow, no breakpoints to declare. Every cell in a row gets the tallest cell's height
via a measure pass, and a trailing partial row is padded so cells don't stretch. Reach for
Grid when you need explicit tracks and spans. Part of the
Responsive toolkit.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add grid
Usage — responsive columns
Columns derive from available width / minChildWidth. This demo box
tracks the page width — narrow the window and the grid reflows.
lotusui.SimpleGrid(gtx, items, 140, 4, th.Space.SM,
func(gtx C, it Item) D { return cell(it)(gtx) })
Equal-height rows
A measure pass finds the tallest cell per row; every sibling gets that height as its minimum — cards in a row stay flush.
// Card honors Constraints.Min.Y for exactly this.
lotusui.SimpleGrid(gtx, entries, 140, 3, th.Space.SM, cell)
API
| Option | Type | Description |
|---|---|---|
items | []T | One cell per item, any type. |
minChildWidth | unit.Dp | Column count derives from available width / this. |
maxCols | int | Upper bound on columns. |
gap | unit.Dp | Spacing between cells, both axes. |
cell | func(C, T) D | Renders one item — a tile, a Card, anything. |