🌈 Create new beautiful Compose Gradients with our new wesite ->
Composable Function

RemoteFitBox

Layout container that renders the first child that fits within available constraints.

RemoteFitBoxSample

@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteFitBoxSample() {
    // The parent RemoteBox constrains the available space to 40.rdp.
    // RemoteFitBox will measure its children against these constraints.
    // Child 1 (50.rdp) is too large to fit, so the RemoteFitBox skips it and selects
    // Child 2 (30.rdp) which fits within the 40.rdp constraints.
    RemoteBox(modifier = RemoteModifier.size(40.rdp).background(Color.LightGray.rc)) {
        RemoteFitBox(
            horizontalAlignment = RemoteAlignment.CenterHorizontally,
            verticalArrangement = RemoteArrangement.Center,
        ) {
            // Child 1: Too large for 40.rdp container
            RemoteBox(RemoteModifier.size(50.rdp).background(Color.Red.rc))

            // Child 2: Fits in 40.rdp container and will be rendered
            RemoteBox(RemoteModifier.size(30.rdp).background(Color.Blue.rc))
        }
    }
}

Content updated: