Composable Function

SelectionContainer

Enables text selection for its direct or indirect children.

SelectionSample

@Sampled
@Composable
fun SelectionSample() {
    SelectionContainer {
        Column {
            Text("Text 1")
            Text("Text 2")
            Text("טקסט 3")
        }
    }
}

SelectAllSample

@Sampled
@Composable
fun SelectAllSample() {
    val selectionState = rememberSelectionState()

    Column {
        Button(onClick = { selectionState.selectAll() }) { BasicText("Select All") }
        SelectionContainer(state = selectionState) { BasicText(text = "Text to be selected...") }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: