# horizontalScroll

Common/AllAndroid/JVM

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/horizontalScroll.modifier#(androidx.compose.ui.Modifier).horizontalScroll(androidx.compose.foundation.ScrollState,kotlin.Boolean,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean)( state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState, enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, flingBehavior: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior?, reverseScrolling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Modify element to allow to scroll horizontally when width of the content is bigger than max constraints allow. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.https://developer.android.com/reference/kotlin/androidx/compose/foundation/horizontalScroll.modifier#(androidx.compose.ui.Modifier).horizontalScroll(androidx.compose.foundation.ScrollState,androidx.compose.foundation.OverscrollEffect,kotlin.Boolean,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean)( state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState, overscrollEffect: https://developer.android.com/reference/kotlin/androidx/compose/foundation/OverscrollEffect?, enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, flingBehavior: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior?, reverseScrolling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Modify element to allow to scroll horizontally when width of the content is bigger than max constraints allow. | Cmn |

## Functions

### Modifier.horizontalScroll

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/Scroll.kt+function:horizontalScroll) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.0.0)

```
fun Modifier.horizontalScroll(
    state: ScrollState,
    enabled: Boolean = true,
    flingBehavior: FlingBehavior? = null,
    reverseScrolling: Boolean = false
): Modifier
```

Modify element to allow to scroll horizontally when width of the content is bigger than max constraints allow.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.unit.dp

val scrollState = rememberScrollState()
val gradient =
    Brush.horizontalGradient(
        listOf(Color.Red, Color.Blue, Color.Green),
        0.0f,
        10000.0f,
        TileMode.Repeated,
    )
Box(
    Modifier.horizontalScroll(scrollState)
        .size(width = 10000.dp, height = 200.dp)
        .background(brush = gradient)
)
```

In order to use this modifier, you need to create and own `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState`

See the other overload in order to provide a custom `https://developer.android.com/reference/kotlin/androidx/compose/foundation/OverscrollEffect`

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState` | state of the scroll |
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether or not scrolling via touch input is enabled |
| `flingBehavior: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior? = null` | logic describing fling behavior when drag has finished with velocity. If `null`, default from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableDefaults#flingBehavior()` will be used. |
| `reverseScrolling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | reverse the direction of scrolling, when `true`, 0 `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState#value()` will mean right, when `false`, 0 `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState#value()` will mean left |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/rememberScrollState.composable#rememberScrollState(kotlin.Int)` |   |

### Modifier.horizontalScroll

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/Scroll.kt+function:horizontalScroll) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.8.0)

```
fun Modifier.horizontalScroll(
    state: ScrollState,
    overscrollEffect: OverscrollEffect?,
    enabled: Boolean = true,
    flingBehavior: FlingBehavior? = null,
    reverseScrolling: Boolean = false
): Modifier
```

Modify element to allow to scroll horizontally when width of the content is bigger than max constraints allow.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.TileMode
import androidx.compose.ui.unit.dp

val scrollState = rememberScrollState()
val gradient =
    Brush.horizontalGradient(
        listOf(Color.Red, Color.Blue, Color.Green),
        0.0f,
        10000.0f,
        TileMode.Repeated,
    )
Box(
    Modifier.horizontalScroll(scrollState)
        .size(width = 10000.dp, height = 200.dp)
        .background(brush = gradient)
)
```

In order to use this modifier, you need to create and own `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState`

| Parameters |
|---|---|
| `state: https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState` | state of the scroll |
| `overscrollEffect: https://developer.android.com/reference/kotlin/androidx/compose/foundation/OverscrollEffect?` | the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/OverscrollEffect` that will be used to render overscroll for this modifier. Note that the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/OverscrollEffect#node()` will be applied internally as well - you do not need to use Modifier.overscroll separately. |
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether or not scrolling via touch input is enabled |
| `flingBehavior: https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/FlingBehavior? = null` | logic describing fling behavior when drag has finished with velocity. If `null`, default from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableDefaults#flingBehavior()` will be used. |
| `reverseScrolling: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | reverse the direction of scrolling, when `true`, 0 `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState#value()` will mean right, when `false`, 0 `https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollState#value()` will mean left |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/rememberScrollState.composable#rememberScrollState(kotlin.Int)` |   |