---
title: "horizontalScroll"
description: "Modify element to allow it to scroll horizontally when its content is larger than its constraints."
type: "function"
---
## API Reference

### horizontalScroll

> Source set: Android

```kotlin
public fun RemoteModifier.horizontalScroll(state: RemoteScrollState): RemoteModifier
```

Modify element to allow it to scroll horizontally when its content is larger than its
constraints.

#### Parameters

| | |
| --- | --- |
| state | The [RemoteScrollState](/jetpack-compose/androidx.compose.remote/remote-creation-compose/classes/RemoteScrollState) that tracks and controls the scroll position. It can be created and remembered using [rememberRemoteScrollState](/jetpack-compose/androidx.compose.remote/remote-creation-compose/composable-functions/rememberRemoteScrollState). |

#### Return

The modified [RemoteModifier](/jetpack-compose/androidx.compose.remote/remote-creation-compose/interfaces/RemoteModifier).

## Code Examples

### HorizontalScrollSample

```kotlin
@Sampled
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun HorizontalScrollSample() {
    val scrollState = rememberRemoteScrollState()
    RemoteRow(
        modifier =
            RemoteModifier.size(200.rdp, 100.rdp)
                .background(Color.LightGray.rc)
                .horizontalScroll(scrollState),
        verticalAlignment = RemoteAlignment.CenterVertically,
    ) {
        for (i in 1..10) {
            RemoteBox(
                modifier =
                    RemoteModifier.size(80.rdp, 80.rdp).padding(5.rdp).background(Color.Red.rc),
                contentAlignment = RemoteAlignment.Center,
            ) {
                RemoteText("Item $i".rs, color = Color.White.rc)
            }
        }
    }
}
```
