Skip to main content

CamoSplitPane

Panes side by side (axis Horizontal, first pane at the start) or stacked, with a draggable, keyboard and screen reader accessible divider between each pair. The state is the app's: fractions of the container and the collapsed panes, which it can snapshot``CamoSplitState.snapshot and restore. A divider moves space between its two neighbours only, within their minSize and maxSize. Arrow keys resize (Shift for a larger step), Home and End go to a limit, Enter collapses or restores a collapsible neighbour, a double-click resets the two neighbours; a screen reader adjusts it like a slider. Right to left mirrors a horizontal split.

Usage​

val state = remember { CamoSplitState(listOf(1f, 3f)) } // fractions, so a saved layout fits any window

CamoSplitPane(
axis = Orientation.Horizontal,
panes = listOf(
CamoPane(minSize = 160.dp, collapsible = true) { Sidebar() },
CamoPane(minSize = 240.dp) { Detail() },
),
state = state,
)

// Save and restore the layout yourself
val saved = state.snapshot()
state.apply(saved)

API​

public fun CamoSplitPane(
axis: Orientation,
panes: List<CamoPane>,
state: CamoSplitState,
modifier: Modifier = Modifier,
)
NameTypeDefault
axisOrientationrequired
panesList<CamoPane>required
stateCamoSplitStaterequired
modifierModifierModifier
Design notes

Why CamoSplitPane works this way, its states and its edge cases: contributor docs.