Jonas
10/28/2025, 12:05 PMOutlinedTextField ;Jonas
10/28/2025, 12:05 PM@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Preview
@Composable
fun Input() {
Column(modifier = Modifier.width(IntrinsicSize.Max)) {
OutlinedTextField(
modifier = Modifier.defaultMinSize(minWidth = Dp.Unspecified),
value = "Hello",
onValueChange = {},
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.End),
singleLine = true
)
Spacer(modifier = Modifier.height(4.dp))
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
val size = ButtonDefaults.ExtraSmallContainerHeight
OutlinedButton(
onClick = { },
modifier = Modifier.heightIn(size),
contentPadding = ButtonDefaults.contentPaddingFor(size),
shape = ButtonDefaults.squareShape,
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "A",
style = ButtonDefaults.textStyleFor(size)
)
}
Button(
onClick = { },
modifier = Modifier.heightIn(size),
contentPadding = ButtonDefaults.contentPaddingFor(size),
shape = ButtonDefaults.squareShape,
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "B",
style = ButtonDefaults.textStyleFor(size)
)
}
OutlinedButton(
onClick = { },
modifier = Modifier.heightIn(size),
contentPadding = ButtonDefaults.contentPaddingFor(size),
shape = ButtonDefaults.squareShape,
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "C",
style = ButtonDefaults.textStyleFor(size)
)
}
OutlinedButton(
onClick = { },
modifier = Modifier.heightIn(size),
contentPadding = ButtonDefaults.contentPaddingFor(size),
shape = ButtonDefaults.squareShape,
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "D",
style = ButtonDefaults.textStyleFor(size)
)
}
}
}
}Jonas
10/28/2025, 12:05 PMJonas
10/28/2025, 12:06 PMJonas
10/28/2025, 12:07 PMIntrinsicSize.Max but had no luck. Somehow the Textfield sees to have an internal min width that takes precedence over the width of the buttons.Filip Wiesner
10/28/2025, 12:09 PM280 dp. The documentatin notes
The default min width applied to an OutlinedTextField. Note that you can override it by applying Modifier.widthIn directly on a text field.
Jonas
10/28/2025, 12:10 PMJonas
10/28/2025, 12:10 PMModifier.defaultMinSize(minWidth = Dp.Unspecified)Jonas
10/28/2025, 12:11 PMwidthIn the text field is always smaller than the buttons.Jonas
10/28/2025, 12:14 PMModifier.widthIn(min = 0.dp),
Looks like this:Jonas
10/28/2025, 12:15 PMModifier.widthIn(min = 200.dp)
looks like this:Filip Wiesner
10/28/2025, 12:34 PMfillMaxWidth. But in this case the button Row is always large so it seems to me that the textfield is reporting it's intrinsic width to be much larger than it actually is. But I don't know enough about this to be certain.
When I tried using just the BasicTextField and borrowed the decoration box from the outlined text field (OutlinedTextFieldDefaults.DecorationBox), it seems to work correctly. So you might try experimenting with thatJonas
10/28/2025, 12:35 PMFilip Wiesner
10/28/2025, 12:36 PMJonas
10/28/2025, 12:37 PMFilip Wiesner
10/28/2025, 12:38 PMJonas
10/28/2025, 12:38 PMFilip Wiesner
10/28/2025, 12:39 PMColumn(modifier = Modifier.width(IntrinsicSize.Min)) {
BasicTextField(
value = "Hello",
onValueChange = {},
textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.End),
singleLine = true,
decorationBox = { innerTextField ->
OutlinedTextFieldDefaults.DecorationBox(
value = "value",
innerTextField = innerTextField,
enabled = true,
singleLine = true,
visualTransformation = VisualTransformation.None,
interactionSource = MutableInteractionSource(),
container = {
OutlinedTextFieldDefaults.Container(
enabled = true,
isError = false,
interactionSource = MutableInteractionSource(),
)
},
)
},
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(4.dp))
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth(),
) {
val size = 48.dp
OutlinedButton(
onClick = { },
modifier = Modifier.heightIn(size),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "A",
)
}
OutlinedButton(
onClick = { },
modifier = Modifier.heightIn(size),
border = BorderStroke(1.dp, MaterialTheme.colorScheme.outline)
) {
Text(
text = "D",
)
}
}
}Jonas
10/28/2025, 12:39 PMFilip Wiesner
10/28/2025, 12:40 PMdecorationBox from the sources of OutlinedTextField. I am not sure if you need all of that. Good luck ☺️Jonas
10/28/2025, 12:40 PM