API reference

TextField Composable

Displays a labeled text input with optional asynchronous validation.

Signature

@Composable
fun TextField(
    value: String,
    label: String,
    onValueChange: (String) -> Unit,
    modifier: Modifier = Modifier,
    onSubmit: (String) -> Unit? = null,
    validation: (String) -> Flow<FieldValidationState>? = null,
    initialValidationState: FieldValidationState = FieldValidationState.Unspecified,
    placeholder: String? = null,
    supportingText: String? = null,
    enabled: Boolean = true,
    leadingIcon: @Composable () -> Unit? = null,
    trailingIcon: @Composable () -> Unit? = null,
    singleLine: Boolean = true,
    autoValidate: Boolean = true,
    autoCorrectEnabled: Boolean = false,
    capitalization: KeyboardCapitalization = KeyboardCapitalization.Unspecified,
    keyboardType: KeyboardType = KeyboardType.Unspecified,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    colors: InputColors = InputDefaults.Colors,
    dimensions: InputDimensions = UiSetTheme.dimensions.inputs,
    shape: Shape = UiSetTheme.shapes.textField,
)

Parameters

value: String current field text
label: String persistent label above the field
onValueChange: (String) -> Unit callback receiving text edits
modifier: Modifier modifier applied to the label, field, and supporting text group
onSubmit: ((String) -> Unit)? optional callback invoked by the keyboard done action
validation: ((String) -> Flow<FieldValidationState>)? optional function producing validation states whenever value changes; a new function takes effect on the next value change
initialValidationState: FieldValidationState state rendered before automatic or caller-driven validation updates, including when autoValidate is false
placeholder: String? text shown when value is empty
supportingText: String? optional guidance or validation message below the field
enabled: Boolean whether the field accepts input
leadingIcon: (@Composable () -> Unit)? optional icon before the editable text
trailingIcon: (@Composable () -> Unit)? optional icon after the text; replaces the default validation icon
singleLine: Boolean whether input is constrained to one line
autoValidate: Boolean whether validation is collected whenever value changes; this does not suppress styling for an explicit initialValidationState
autoCorrectEnabled: Boolean whether the keyboard may autocorrect input
capitalization: KeyboardCapitalization keyboard capitalization behavior
keyboardType: KeyboardType requested software keyboard type
interactionSource: MutableInteractionSource interaction stream shared with callers observing field state
colors: InputColors container, content, focus, validation, placeholder, and disabled colors
dimensions: InputDimensions field height, icon, padding, spacing, and border geometry
shape: Shape field container shape