StylishFormTextField

fun StylishFormTextField(value: String, onValueChange: (String) -> Unit, label: String = "", placeholder: String = "", modifier: Modifier = Modifier, minLines: Int = 1, maxLines: Int = if (minLines == 1) 1 else Int.MAX_VALUE, isError: Boolean = false, errorMessage: String? = null, leadingIcon: @Composable () -> Unit? = null, trailingIcon: @Composable () -> Unit? = null, textStyle: TextStyle = MaterialTheme.typography.bodyLarge, shape: Shape = OutlinedTextFieldDefaults.shape, colors: TextFieldColors? = null, enabled: Boolean = true, readOnly: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, labelContent: @Composable () -> Unit? = null, placeholderContent: @Composable () -> Unit? = null, supportingContent: @Composable () -> Unit? = null, fieldModifier: Modifier = Modifier, cursorBrush: Brush = SolidColor(Color.Black), singleLine: Boolean = false, interactionSource: MutableInteractionSource? = null, prefix: @Composable () -> Unit? = null, suffix: @Composable () -> Unit? = null)

An outlined text field designed for form input, with built-in label, placeholder, and error-message support. Wraps Material's OutlinedTextField inside a Column and fills the available width.

When minLines is 1 and maxLines is 1 (the default), the field operates in single-line mode. Setting minLines greater than 1 switches to a multiline field whose maxLines defaults to Int.MAX_VALUE. When singleLine is true, both minLines and maxLines are forced to 1 (matching Material's single-line contract).

Error display follows a priority chain: if supportingContent is provided it is used as-is; otherwise, when errorMessage is non-null, it is rendered as supporting text in MaterialTheme.colorScheme.error. The isError flag independently controls the field's error outline color.

A character counter can be added by passing a counter composable via supportingContent (e.g. { Text("${value.length} / 100") }); no counter is added automatically.

Parameters

value

Current text value (controlled state).

onValueChange

Called with the updated text on every edit.

label

Label displayed above the field. Defaults to "", which renders no label region at all. Overridden by labelContent when provided.

placeholder

Hint text shown when the field is empty. Defaults to "", which renders no placeholder region at all. Overridden by placeholderContent when provided.

minLines

Minimum visible lines. Defaults to 1. Ignored when singleLine is true.

maxLines

Maximum lines before scrolling. Defaults to 1 when minLines is 1, otherwise Int.MAX_VALUE. Ignored when singleLine is true.

isError

When true, the field renders its error outline color. Independent of errorMessage.

errorMessage

Error text displayed below the field in the error color. Ignored when supportingContent is provided.

leadingIcon

Optional icon slot at the start of the field.

trailingIcon

Optional icon slot at the end of the field.

textStyle

Typography for the input text. Defaults to MaterialTheme.typography.bodyLarge.

shape

Shape of the outlined border. Defaults to OutlinedTextFieldDefaults.shape.

colors

Color scheme for the field. Defaults to OutlinedTextFieldDefaults.colors(), with the cursor color derived from cursorBrush when it is a solid color.

enabled

When false, the field rejects input and renders in Material's disabled color scheme. Defaults to true.

readOnly

When true, the field displays its text without allowing edits. Defaults to false.

keyboardOptions

Software keyboard options (keyboard type, capitalization, IME action) for the field.

keyboardActions

Software keyboard action handlers for the field.

visualTransformation

Visual transformation applied to the input text (e.g. password masking). Defaults to VisualTransformation.None.

labelContent

Optional slot that replaces the default Text label built from label.

placeholderContent

Optional slot that replaces the default Text placeholder built from placeholder.

supportingContent

Optional slot rendered below the field, replacing errorMessage when provided. Use this for counters and helper text.

fieldModifier

Modifier applied to the inner OutlinedTextField, before fillMaxWidth in the modifier chain (i.e. fieldModifier.fillMaxWidth()). Use this to add test tags or input-specific modifiers without affecting the outer Column.

cursorBrush

Brush used for the text cursor. Defaults to SolidColor of Color.Black. Note: Material's string-based OutlinedTextField derives the cursor from its colors' cursorColor, so a SolidColor brush is honored through the default colors, while non-solid brushes fall back to the theme cursor color; an explicit colors overrides the brush.

singleLine

When true, forces single-line mode: minLines and maxLines are set to 1 and the field scrolls horizontally instead of wrapping. When false (default), single-line mode is derived from minLines and maxLines as before.

interactionSource

The MutableInteractionSource for the field, used to observe focus/press/hover interactions. When null, an internal one is remembered.

prefix

Optional slot rendered inline before the input text (e.g. a currency symbol).

suffix

Optional slot rendered inline after the input text (e.g. a unit).