Compose Modifier

size

Declare the preferred size of the content to be exactly sizedp square.

SimpleSizeModifier

@Sampled
@Composable
fun SimpleSizeModifier() {
    Box { Box(Modifier.size(100.dp, 100.dp).background(Color.Red)) }
}

SimpleSizeModifierWithDpSize

@Sampled
@Composable
fun SimpleSizeModifierWithDpSize() {
    Box { Box(Modifier.size(DpSize(100.dp, 100.dp)).background(Color.Red)) }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: