Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the input font size in TextField of Android Jetpack Compose

I'd like to change the input font size in TextField of Android Jetpack Compose because it's very small now. Like this

like image 691
Yuki Avatar asked Dec 13 '25 15:12

Yuki


1 Answers

Update:

I don't recall if the parameter was originally present when I originally answered, but there is a fontSize parameter on both the M2 and M3 Text composable that you can set directly and still have it respect the theme (think of it as a one off override)


According to the documentation, there is a parameter textStyle that takes TextStyle that allows you to set font size via fontSize.

You can do the following and it will set the font size to 28 sp

   TextField(value = "", onValueChange = {}, textStyle = TextStyle.Default.copy(fontSize = 28.sp))

note: if you want to ensure that your themed style still applies and you're just modifying the size of it, use LocalTextStyle.current.merge(TextStyle(fontSize = 28.sp)) or LocalTextStyle.current.copy(fontSize = 28.sp) instead of TextStyle.Default.copy(fontSize = 28.sp)

like image 83
undermark5 Avatar answered Dec 15 '25 08:12

undermark5