Search code examples
androidandroid-jetpack-composetextfieldandroid-jetpack

Textfield takes extra space in Jetpack Compose


When I am trying to put another composable next to TextField, TextField takes extra place.enter image description here

Red is TextField. Orange is the composable that should be next to it exactly.

I tried to use .widthIn(1.dp, Dp.Infinity) on Modifier

Also I noticed that TextField has this

modifier = modifier
                .defaultMinSize(
                    minWidth = TextFieldDefaults.MinWidth,
                    minHeight = TextFieldDefaults.MinHeight
                )

on its Modifier, val MinWidth = 280.dp


Solution

  • So, basically I used BasicTextField and added .width(IntrinsicSize.Min) in its Modifier