Skip to content

PinchGridState

Creating state

val state = rememberPinchGridState(
initialColumnCount = 3,
minColumns = 1,
maxColumns = 5,
)

rememberPinchGridState uses rememberSaveable — the column count survives configuration changes.

Properties

PropertyTypeDescription
columnCountIntCurrent committed column count (read-only)
previousColumnCountIntColumn count before the last change (read-only)
scaleProgressFloat0f–1f progress toward next snap (read-only)
isZoomingInBoolean?true = spreading, false = pinching, null = idle (read-only)
minColumnsIntMinimum allowed columns
maxColumnsIntMaximum allowed columns

Methods

snapToColumn

fun snapToColumn(target: Int)

Programmatically change the column count. The target is clamped to minColumns..maxColumns. Triggers haptic feedback and onColumnChanged callback.

Saver

PinchGridState provides a custom Saver for rememberSaveable:

PinchGridState.Saver(minColumns = 1, maxColumns = 5)

This saves and restores the columnCount across configuration changes.