Interface

FlexBoxScope

Scope for the content of a FlexBox.

FlexBoxScopeSample

@Sampled
@Composable
fun FlexBoxScopeSample() {
    // FlexConfig can be defined as top-level constants for reuse
    val NoShrink = FlexConfig { shrink(0f) }

    FlexBox {
        // Basic item without flex configuration
        Box(Modifier.size(50.dp).background(Color.Red))

        // Item with inline flex configuration
        Box(Modifier.size(50.dp).background(Color.Green).flex { grow(1f) })

        // Item with reusable FlexConfig
        Box(Modifier.size(50.dp).background(Color.Blue).flex(NoShrink))
    }
}
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: