TextInput

fun TextInput(label: String, value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, placeholderText: String = "", helperText: String = "", state: TextInputState = TextInputState.Enabled, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

Text input

Text inputs enable users to enter free-form text data. The type of text field used should reflect the length of the content you expect the user to enter. The default text input is for short, one-line content, whereas text area is for longer, multi-line entries.

Implementation note:

As per Carbon's documentation, the text input can have three different sizes. However, the small and medium sizes does not comply with accessibility on Android, as the minimum touch target size for an interactible component should be at least 48dp. This implementation then provides only the large text input.

(From Text input documentation)

Parameters

label

Text that informs the user about the content they need to enter in the field.

value

The input String text to be shown in the text input.

onValueChange

The callback that is triggered when the input service updates the text. An updated text comes as a parameter of the callback

modifier

Optional Modifier for this text input.

placeholderText

Optionnal text that provides hints or examples of what to enter.

helperText

Optional helper text is pertinent information that assists the user in correctly completing a field. It is often used to explain the correct data format.

state

The interactive state of the text input.

keyboardOptions

software keyboard options that contains configuration such as KeyboardType and ImeAction.

keyboardActions

when the input service emits an IME action, the corresponding callback is called. Note that this IME action may be different from what you specified in KeyboardOptions.imeAction.

visualTransformation

The visual transformation filter for changing the visual representation of the input. By default no visual transformation is applied.

interactionSource

the MutableInteractionSource representing the stream of Interactions for this TextField. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this TextField in different Interactions.