GroupedGrid

fun GroupedGrid(items: ImmutableList<GroupedGridItem>, modifier: Modifier = Modifier, columns: Int = GroupedGridDefaults.Columns, measurements: GroupedGridMeasurements = GroupedGridDefaults.Measurements, outerRadius: Dp = GroupedGridDefaults.OuterRadius, innerRadius: Dp = GroupedGridDefaults.InnerRadius, itemSpacing: Dp = GroupedGridDefaults.ItemSpacing, iconShape: Shape = GroupedGridDefaults.IconShape, colors: GroupedGridColors = GroupedGridDefaults.colors(), bounceOnClick: Boolean = false, adUnitId: String? = null)(source)

A block of category cells laid out as one rounded group.

The group is the unit, not the cell: only the corners at the outside of the block are rounded at outerRadius, every corner where two cells meet is cut at innerRadius, and the cells are separated by itemSpacing rather than floating as separate cards. It is the layout a storage breakdown or a media summary is read in: a badge, what the row is, and how big it is. It works just as well for a block of actions, where a cell has no subtitle.

What a caller chooses:

  • measurements sets the height of a cell and everything that scales with it, the way a size class does for a button.

  • outerRadius and innerRadius set how hard the group and its seams are cut.

  • iconShape cuts the icon badge, and a GroupedGridItem may override it per cell. Any Shape works, so MaterialShapes.Cookie9Sided.toShape() and the rest of the Material 3 shape set are available without the toolkit shipping artwork of its own.

  • columns sets how many cells share a row. A last row that is short shares its width between the cells it does have, so a lone leftover item spans the row.

Passing an adUnitId adds one native ad row spanning the full width, in the middle of the block, from GroupedGridDefaults.MinItemsForAd items up. The ad is part of the group: it is cut with the same radii, and takes the same badge, padding and headline size as the cells, so it reads as one more row rather than as something dropped between them. A grid of one cell never shows one, and neither does a grid whose ad fails to load, where the cells round off exactly as they would have without it. Placement policy stays with the host, which decides whether to pass a unit id at all.

Parameters

items

Cells to render, in order. An empty list renders nothing.

bounceOnClick

true scales a cell down while it is held. Off by default: a grid is read as one block, and a cell that shrinks on its own breaks the block apart.

adUnitId

AdMob native ad unit for the ad row. null or blank renders no ad row.