# BottomSheetState

Artifact: [androidx.compose.material:material](https://developer.android.com/jetpack/androidx/releases/compose-material) [View Source](https://cs.android.com/search?q=file:androidx/compose/material/BottomSheetScaffold.kt+class:androidx.compose.material.BottomSheetState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class BottomSheetState
  ```

*** ** * ** ***

State of the persistent bottom sheet in `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetScaffold.composable#BottomSheetScaffold(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.BottomSheetScaffoldState,kotlin.Function0,kotlin.Function1,kotlin.Function0,androidx.compose.material.FabPosition,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,kotlin.Function1)`.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,androidx.compose.ui.unit.Density)( animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, confirmStateChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density )` The default `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,androidx.compose.ui.unit.Density)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState`. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#BottomSheetState(androidx.compose.material.BottomSheetValue,androidx.compose.ui.unit.Density,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)( initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue, density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density, animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, confirmValueChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` | Cmn |

| ### Public functions |
|---|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#collapse()()` Collapse the bottom sheet with animation and suspend until it if fully collapsed or animation has been cancelled. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#expand()()` Expand the bottom sheet with an animation and suspend until the animation finishes or is cancelled. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)(from: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue, to: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue)` The fraction of the offset between `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)` and `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)`, as a fraction between 0f..1f, or 1f if `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)` is equal to `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#requireOffset()()` Require the current offset. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#currentValue()` The current value of the `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#isCollapsed()` Whether the bottom sheet is collapsed. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#isExpanded()` Whether the bottom sheet is expanded. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/material/ExperimentalMaterialApi https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress()` **This property is deprecated.** Please use the progress function to query progress explicitly between targets. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#targetValue()` The target value the state will settle at once the current interaction ends, or the `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#currentValue()` if there is no interaction in progress. | Cmn |

## Public companion functions

### Saver

Cmn Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.5.0)

```
fun Saver(
    animationSpec: AnimationSpec<Float>,
    confirmStateChange: (BottomSheetValue) -> Boolean,
    density: Density
): Saver<BottomSheetState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,androidx.compose.ui.unit.Density)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState`.

## Public constructors

### BottomSheetState

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.7.0)

```
BottomSheetState(
    initialValue: BottomSheetValue,
    density: Density,
    animationSpec: AnimationSpec<Float> = BottomSheetScaffoldDefaults.AnimationSpec,
    confirmValueChange: (BottomSheetValue) -> Boolean = { true }
)
```

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue` | The initial value of the state. |
| `density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density` | The density that this state can use to convert values to and from dp. |
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> = BottomSheetScaffoldDefaults.AnimationSpec` | The default animation that will be used to animate to a new state. |
| `confirmValueChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = { true }` | Optional callback invoked to confirm or veto a pending state change. |

## Public functions

### collapse

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0)

```
suspend fun collapse(): Unit
```

Collapse the bottom sheet with animation and suspend until it if fully collapsed or animation has been cancelled. This method will throw `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-cancellation-exception/index.html` if the animation is interrupted.

### expand

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0)

```
suspend fun expand(): Unit
```

Expand the bottom sheet with an animation and suspend until the animation finishes or is cancelled. Note: If the peek height is equal to the sheet height, this method will animate to the `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue#Collapsed` state.

This method will throw `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-cancellation-exception/index.html` if the animation is interrupted.

### progress

Cmn Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.7.0)

```
fun progress(from: BottomSheetValue, to: BottomSheetValue): @FloatRange(from = 0.0, to = 1.0) Float
```

The fraction of the offset between `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)` and `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)`, as a fraction between 0f..1f, or 1f if `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)` is equal to `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#progress(androidx.compose.material.BottomSheetValue,androidx.compose.material.BottomSheetValue)`.

| Parameters |
|---|---|
| `from: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue` | The starting value used to calculate the distance |
| `to: https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetValue` | The end value used to calculate the distance |

### requireOffset

Cmn Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.4.0)

```
fun requireOffset(): Float
```

Require the current offset.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | If the offset has not been initialized yet |

## Public properties

### currentValue

Cmn

```
val currentValue: BottomSheetValue
```

The current value of the `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState`.

### isCollapsed

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0)

```
val isCollapsed: Boolean
```

Whether the bottom sheet is collapsed.

### isExpanded

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0)

```
val isExpanded: Boolean
```

Whether the bottom sheet is expanded.

### progress

Cmn

```
@ExperimentalMaterialApi
val progress: Float
```

> [!CAUTION]
> **This property is deprecated.**   
> Please use the progress function to query progress explicitly between targets, use this instead:
>
> ```kotlin
> progress(from = , to = )
> ```

The fraction of the progress, within 0f..1f bounds, or 1f if the `https://developer.android.com/reference/kotlin/androidx/compose/material/AnchoredDraggableState` is in a settled state.

### targetValue

Cmn

```
val targetValue: BottomSheetValue
```

The target value the state will settle at once the current interaction ends, or the `https://developer.android.com/reference/kotlin/androidx/compose/material/BottomSheetState#currentValue()` if there is no interaction in progress.