Mokera

Tech Sheets

mokelab

Specifying Width in Jetpack Compose

Last updated:2024-06-16

To set the width of a Composable to a specific size, pass Modifier.width() to the modifier parameter. The unit is dp .

@Composable
fun Greeting(name: String) {
    Row {
        Text(text = "ねぇ", modifier = Modifier.width(60.dp))
        Text(text = "$name!")
    }
}

"ねぇ" text width is set to 60dp instead of content size.

Back