TextArea

fun TextArea(label: String, value: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier, placeholderText: String = "", helperText: String = "", state: TextInputState = TextInputState.Enabled, counter: Pair<Int, Int>? = null, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, maxLines: Int = Int.MAX_VALUE, minLines: Int = 1, visualTransformation: VisualTransformation = VisualTransformation.None, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

Text area

Use a text area when the expected user input is more than a few words and could span multiple lines. Text area has several unique functionalities not included in the text input, like the resize handle, word counter and character counter.

Implementation note:

As per Carbon's documentation, the text area component has a minimum height of 40px/2.5rem, but regarding accessibility on Android, this value is revised to the Large text input size, as it complies with accessibility.

(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.

counter

Word/character counter values to be displayed next to the label. The first value is the current count and the second value is the maximum value.

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.

maxLines

the maximum height in terms of maximum number of visible lines. It is required that 1 <= minLines<= maxLines. This parameter is ignored when singleLine is true.

minLines

the minimum height in terms of minimum number of visible lines. It is required that 1 <= minLines<= maxLines. This parameter is ignored when singleLine is true.

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.