---
title: "RemoteStateLayout"
description: "A layout that manages and displays multiple states defined by a [RemoteEnum]."
type: "composable"
---
## API Reference

### RemoteStateLayout

> Source set: Android

```kotlin
@Composable
public fun <T : Enum<T>> RemoteStateLayout(
    currentState: RemoteEnum<T>,
    modifier: RemoteModifier = RemoteModifier,
    content: @Composable (T) -> Unit,
)
```

A layout that manages and displays multiple states defined by a [RemoteEnum](/jetpack-compose/androidx.compose.remote/remote-creation-compose/classes/RemoteEnum/api).

This component ensures that all possible states defined in the [RemoteEnum](/jetpack-compose/androidx.compose.remote/remote-creation-compose/classes/RemoteEnum/api) are composed, while
the underlying remote rendering system handles the visibility and transitions between them based
on the `currentState`.

#### Parameters

| | |
| --- | --- |
| currentState | The state machine governing the available states and the current active state. |
| modifier | The [RemoteModifier](/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier) to be applied to this layout. |
| content | A composable lambda that defines the UI for each state `T`. |

### RemoteStateLayout

> Source set: Android

```kotlin
@Composable
public fun RemoteStateLayout(
    currentState: RemoteBoolean,
    modifier: RemoteModifier = RemoteModifier,
    content: @Composable (Boolean) -> Unit,
)
```

A layout that manages and displays two states defined by a [RemoteBoolean](/jetpack-compose/androidx.compose.remote/remote-creation-compose/classes/RemoteBoolean/api).

This component ensures that both possible states are composed, while the underlying remote
rendering system handles the visibility and transitions between them based on the `currentState`.

#### Parameters

| | |
| --- | --- |
| currentState | The state machine governing the available states and the current active state. |
| modifier | The [RemoteModifier](/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier) to be applied to this layout. |
| content | A composable lambda that defines the UI for each state `Boolean`. |

### RemoteStateLayout

> Source set: Android

```kotlin
@Composable
public fun RemoteStateLayout(
    currentState: RemoteInt,
    vararg states: Int,
    modifier: RemoteModifier = RemoteModifier,
    content: @Composable (Int) -> Unit,
)
```

A layout that manages and displays multiple states defined by a [RemoteInt](/jetpack-compose/androidx.compose.remote/remote-creation-compose/classes/RemoteInt/api).

This component ensures that all possible states defined in `states` are composed, while the
underlying remote rendering system handles the visibility and transitions between them based on
the `RemoteStateMachine.currentState`.

#### Parameters

| | |
| --- | --- |
| currentState | The state machine governing the available states and the current active state. |
| states | The list of integer states that this layout can display. |
| modifier | The [RemoteModifier](/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier) to be applied to this layout. |
| content | A composable lambda that defines the UI for each state `Int`. |

## Code Examples

### RemoteStateLayoutEnumSample

```kotlin
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutEnumSample() {
    val state = rememberMutableRemoteEnum(SampleState.Loading)
    RemoteStateLayout(currentState = state) { screen ->
        when (screen) {
            SampleState.Loading -> RemoteText("Loading...".rs, color = Color.Gray.rc)
            SampleState.Success -> RemoteText("Success!".rs, color = Color.Green.rc)
            SampleState.Error -> RemoteText("Error occurred".rs, color = Color.Red.rc)
        }
    }
}
```

### RemoteStateLayoutBooleanSample

```kotlin
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutBooleanSample() {
    val state = rememberMutableRemoteBoolean(true)
    RemoteStateLayout(currentState = state) { isTrue ->
        if (isTrue) {
            RemoteText("True State".rs, color = Color.Green.rc)
        } else {
            RemoteText("False State".rs, color = Color.Red.rc)
        }
    }
}
```

### RemoteStateLayoutIntSample

```kotlin
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun RemoteStateLayoutIntSample() {
    val state = rememberMutableRemoteInt(0)
    RemoteStateLayout(currentState = state, 0, 1, 2) { index ->
        when (index) {
            0 -> RemoteText("State 0".rs, color = Color.Red.rc)
            1 -> RemoteText("State 1".rs, color = Color.Green.rc)
            2 -> RemoteText("State 2".rs, color = Color.Blue.rc)
        }
    }
}

enum class SampleState {
    Loading,
    Success,
    Error,
}
```
