Issue
Is there a way to disable all interaction for Jetpack Compose's TextField?
Solution
With 1.0.0
you can use the href="https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#textfield" rel="noreferrer">enabled
attribute:
enabled
: controls the enabled state of the TextField
. When false
, the text field will be neither editable nor focusable, the input of the text field will not be selectable, visually text field will appear in the disabled UI state
Something like:
var text by rememberSaveable { mutableStateOf("Text") }
TextField(
value = text,
onValueChange = { text = it },
enabled = false,
label = { Text("Label") },
singleLine = true
)
Answered By - Gabriele Mariotti
Answer Checked By - Pedro (JavaFixing Volunteer)