Search code examples
androidandroid-jetpack-composeandroid-textinputlayoutandroid-compose-textfield

Change the radius of the border for OutlinedTextField


Is it possible to change the radius of the border of an OutlinedTextField. I want to achieve something like this TextField with desired border

I can not use Modifier.border because it just draws border above the label. Like this OutlinedTextField with border applied

And for OutlinedTextField there is no shape parameter like it is in TextField. And If I use simple TextField I can't have label that is drawing in the top border line. The label is drawing within the TextField.


Solution

  • You can use the shape parameter to customize the shape of the border:

    OutlinedTextField(
        value = text,
        onValueChange = {
            text = it
        },
        shape = RoundedCornerShape(12.dp)
    )
    

    enter image description here

    enter image description here