Compose Unstyled 2.0 is out! Check the official announcement blog ->
Class

SelectionState

Selection state object for a particular SelectionContainer.

SelectionStateSample

@Composable
fun SelectionStateSample() {
    val selectionState = rememberSelectionState()
    val characterCount = selectionState.selectedTexts.sumOf { it.text.length }
    Column {
        SelectionContainer(state = selectionState) {
            Column { BasicText(text = "Text to be selected...") }
        }
        if (characterCount > 0) {
            BasicText(text = "Characters selected: $characterCount")
        }
    }
}

Last updated: