androidx.compose.foundation.text.selection


Classes

TextSelectionColors

Represents the colors used for text selection by text and text field components.

Cmn

Top-level functions summary

Unit

Disables text selection for its direct or indirect children.

Cmn
Unit
@Composable
SelectionContainer(modifier: Modifier, content: @Composable () -> Unit)

Enables text selection for its direct or indirect children.

Cmn

Top-level properties summary

ProvidableCompositionLocal<TextSelectionColors>

CompositionLocal used to change the TextSelectionColors used by text and text field components in the hierarchy.

Cmn

Top-level functions

DisableSelection

@Composable
fun DisableSelection(content: @Composable () -> Unit): Unit

Disables text selection for its direct or indirect children. To use this, simply add this to wrap one or more text composables.

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text

SelectionContainer {
    Column {
        Text("Text 1")

        DisableSelection {
            Text("Text 2")
            Text("טקסט 3")
        }

        Text("Text 3")
    }
}

SelectionContainer

@Composable
fun SelectionContainer(
    modifier: Modifier = Modifier,
    content: @Composable () -> Unit
): Unit

Enables text selection for its direct or indirect children.

Use of a lazy layout, such as LazyRow or LazyColumn, within a SelectionContainer has undefined behavior on text items that aren't composed. For example, texts that aren't composed will not be included in copy operations and select all will not expand the selection to include them.

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text

SelectionContainer {
    Column {
        Text("Text 1")
        Text("Text 2")
        Text("טקסט 3")
    }
}

Top-level properties

LocalTextSelectionColors

val LocalTextSelectionColorsProvidableCompositionLocal<TextSelectionColors>

CompositionLocal used to change the TextSelectionColors used by text and text field components in the hierarchy.