Text Field
A foundational component used to build text fields.
For interactive preview & code examples, visit Text Field Documentation.
Basic Example
var text by remember { mutableStateOf("") }
TextField(
value = text,
onValueChange = { text = it },
placeholder = "Enter text",
shape = RoundedCornerShape(8.dp),
backgroundColor = Color.White,
borderColor = Color(0xFFE4E4E4),
borderWidth = 1.dp
)Parameters
The input text to be shown in the text field.
The callback that is triggered when the input service updates the text.
Whether the text field is editable.
Modifier to be applied to the text field.
Padding values for the content.
Optional composable to be shown at the start of the text field.
Optional composable to be shown at the end of the text field.
The placeholder composable to be shown when the text field is empty.
The color of the text.
The color of the text when the text field is disabled.
The background color of the text field.
The width of the border.
The color of the border.
The shape of the text field.
The style of the text.
The alignment of the text.
The size of the text.
The weight of the text.
The font family of the text.
Whether the text field should be constrained to a single line.
The minimum number of lines to be shown.
The maximum number of lines to be shown.
The keyboard options for the text field.
The keyboard actions for the text field.
The interaction source for the text field.
The spacing between the leading icon, text, and trailing icon.
The visual transformation to be applied to the text.
The vertical alignment of the content.