Member-only story
BasicTextField in Material 3 Jetpack Compose (with Examples)
Published in
5 min readJan 15, 2025

In this article, we’ll learn how to implement custom text fields using BasicTextField
API in Material 3 Jetpack Compose.
First, What is BasicTextField?
It helps us to create a fully customized input field. Unlike, TextFiled
, it has no decorations. If you want to create an input field without following material guidelines, basic text field is the right choice for you.
The API looks like this:
@Composable
fun BasicTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = TextStyle.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
singleLine: Boolean = false,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
visualTransformation: VisualTransformation = VisualTransformation.None,
onTextLayout: (TextLayoutResult) -> Unit = {},
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
cursorBrush: Brush = SolidColor(Color.Black),
decorationBox: @Composable (innerTextField: @Composable () -> Unit) -> Unit =
@Composable { innerTextField ->…