# ModalBottomSheetState

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/ModalBottomSheet.kt+class:androidx.compose.material.ModalBottomSheetState) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  class ModalBottomSheetState
  ```

*** ** * ** ***

State of the `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetLayout.composable#ModalBottomSheetLayout(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.ModalBottomSheetState,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.graphics.Color,kotlin.Function0)` composable.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,kotlin.Boolean,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/ModalBottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, skipHalfExpanded: 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/ModalBottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,kotlin.Boolean,androidx.compose.ui.unit.Density)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState`. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#ModalBottomSheetState(androidx.compose.material.ModalBottomSheetValue,androidx.compose.ui.unit.Density,kotlin.Function1,androidx.compose.animation.core.AnimationSpec,kotlin.Boolean)( initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue, density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density, confirmValueChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, isSkipHalfExpanded: 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/ModalBottomSheetState#hide()()` Hide the bottom sheet with animation and suspend until it if fully hidden or animation has been 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/ModalBottomSheetState#progress(androidx.compose.material.ModalBottomSheetValue,androidx.compose.material.ModalBottomSheetValue)(from: https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue, to: https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue)` The fraction of the offset between `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#progress(androidx.compose.material.ModalBottomSheetValue,androidx.compose.material.ModalBottomSheetValue)` and `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#progress(androidx.compose.material.ModalBottomSheetValue,androidx.compose.material.ModalBottomSheetValue)`, as a fraction between 0f..1f, or 1f if `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#progress(androidx.compose.material.ModalBottomSheetValue,androidx.compose.material.ModalBottomSheetValue)` is equal to `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#progress(androidx.compose.material.ModalBottomSheetValue,androidx.compose.material.ModalBottomSheetValue)`. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#show()()` Show the bottom sheet with animation and suspend until it's shown. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#currentValue()` The current value of the `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#isVisible()` Whether the bottom sheet is visible. | 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/ModalBottomSheetState#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/ModalBottomSheetValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#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/ModalBottomSheetState#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>,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean,
    skipHalfExpanded: Boolean,
    density: Density
): Saver<ModalBottomSheetState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#Saver(androidx.compose.animation.core.AnimationSpec,kotlin.Function1,kotlin.Boolean,androidx.compose.ui.unit.Density)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState`. Saves the `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#currentValue()` and recreates a `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState` with the saved value as initial value.

## Public constructors

### ModalBottomSheetState

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

```
ModalBottomSheetState(
    initialValue: ModalBottomSheetValue,
    density: Density,
    confirmValueChange: (ModalBottomSheetValue) -> Boolean = { true },
    animationSpec: AnimationSpec<Float> = ModalBottomSheetDefaults.AnimationSpec,
    isSkipHalfExpanded: Boolean = false
)
```

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue` | The initial value of the state. **Must not be set to `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue#HalfExpanded` if `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetState#isSkipHalfExpanded()` is set to true.** |
| `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. |
| `confirmValueChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = { true }` | Optional callback invoked to confirm or veto a pending state change. |
| `animationSpec: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> = ModalBottomSheetDefaults.AnimationSpec` | The default animation that will be used to animate to a new state. |
| `isSkipHalfExpanded: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = false` | Whether the half expanded state, if the sheet is tall enough, should be skipped. If true, the sheet will always expand to the `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue#Expanded` state and move to the `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue#Hidden` state when hiding the sheet, either programmatically or by user interaction. **Must not be set to true if the initialValue is `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue#HalfExpanded`.** If supplied with `https://developer.android.com/reference/kotlin/androidx/compose/material/ModalBottomSheetValue#HalfExpanded` for the initialValue, an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` will be thrown. |

## Public functions

### hide

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

```
suspend fun hide(): Unit
```

Hide the bottom sheet with animation and suspend until it if fully hidden or animation has been cancelled.

### progress

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

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

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

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

### show

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

```
suspend fun show(): Unit
```

Show the bottom sheet with animation and suspend until it's shown. If the sheet is taller than 50% of the parent's height, the bottom sheet will be half expanded. Otherwise it will be fully expanded.

## Public properties

### currentValue

Cmn

```
val currentValue: ModalBottomSheetValue
```

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

### isVisible

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

```
val isVisible: Boolean
```

Whether the bottom sheet is visible.

### 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: ModalBottomSheetValue
```

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