# DrawerState

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

  ```
  class DrawerState
  ```

*** ** * ** ***

State of the `https://developer.android.com/reference/kotlin/androidx/compose/material/package-summary#ModalDrawer(kotlin.Function1,androidx.compose.ui.Modifier,androidx.compose.material.DrawerState,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/DrawerState, https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue>` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#Saver(kotlin.Function1)(confirmStateChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` The default `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#Saver(kotlin.Function1)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState`. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#DrawerState(androidx.compose.material.DrawerValue,kotlin.Function1)( initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue, confirmStateChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue) -> 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/ExperimentalMaterialApi [animateTo](https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#animateTo(androidx.compose.material.DrawerValue,androidx.compose.animation.core.AnimationSpec))(targetValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue, anim: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>)` **This function is deprecated.** This method has been replaced by the open and close methods. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#close()()` Close the drawer with animation and suspend until it if fully closed 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/DrawerState#open()()` Open the drawer with animation and suspend until it if fully opened 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/DrawerState#snapTo(androidx.compose.material.DrawerValue)(targetValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue)` Set the state without any animation and suspend until it's set | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#currentValue()` The current value of the state. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#isAnimationRunning()` Whether the state is currently animating. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#isClosed()` Whether the drawer is closed. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#isOpen()` Whether the drawer is open. | 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/DrawerState#offset()` The current position (in pixels) of the drawer sheet, or `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/-companion/-na-n.html` before the offset is initialized. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue` | `@https://developer.android.com/reference/kotlin/androidx/compose/material/ExperimentalMaterialApi https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#targetValue()` The target value of the drawer state. | Cmn |

## Public companion functions

### Saver

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

```
fun Saver(confirmStateChange: (DrawerValue) -> Boolean): Saver<DrawerState, DrawerValue>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#Saver(kotlin.Function1)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState`.

## Public constructors

### DrawerState

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

```
DrawerState(
    initialValue: DrawerValue,
    confirmStateChange: (DrawerValue) -> Boolean = { true }
)
```

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue` | The initial value of the state. |
| `confirmStateChange: (https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue) -> 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

### animateTo

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

```
@ExperimentalMaterialApi
suspend fun [animateTo](https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#animateTo(androidx.compose.material.DrawerValue,androidx.compose.animation.core.AnimationSpec))(targetValue: DrawerValue, anim: AnimationSpec<Float>): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> This method has been replaced by the open and close methods. The animation spec is now an implementation detail of ModalDrawer.

Set the state of the drawer with specific animation

| Parameters |
|---|---|
| `targetValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue` | The new value to animate to. |
| `anim: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | Set the state of the drawer with specific animation |

### close

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

```
suspend fun close(): Unit
```

Close the drawer with animation and suspend until it if fully closed 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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | the reason the close animation ended |

### open

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

```
suspend fun open(): Unit
```

Open the drawer with animation and suspend until it if fully opened 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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | the reason the open animation ended |

### snapTo

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

```
suspend fun snapTo(targetValue: DrawerValue): Unit
```

Set the state without any animation and suspend until it's set

| Parameters |
|---|---|
| `targetValue: https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerValue` | The new target value |

## Public properties

### currentValue

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

```
val currentValue: DrawerValue
```

The current value of the state.

If no swipe or animation is in progress, this corresponds to the start the drawer currently in. If a swipe or an animation is in progress, this corresponds the state drawer was in before the swipe or animation started.

### isAnimationRunning

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

```
val isAnimationRunning: Boolean
```

Whether the state is currently animating.

### isClosed

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

```
val isClosed: Boolean
```

Whether the drawer is closed.

### isOpen

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

```
val isOpen: Boolean
```

Whether the drawer is open.

### offset

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

```
@ExperimentalMaterialApi
val offset: Float
```

The current position (in pixels) of the drawer sheet, or `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/-companion/-na-n.html` before the offset is initialized.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material/AnchoredDraggableState#offset()` | for more information. |

### targetValue

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

```
@ExperimentalMaterialApi
val targetValue: DrawerValue
```

The target value of the drawer state.

If a swipe is in progress, this is the value that the Drawer would animate to if the swipe finishes. If an animation is running, this is the target value of that animation. Finally, if no swipe or animation is in progress, this is the same as the `https://developer.android.com/reference/kotlin/androidx/compose/material/DrawerState#currentValue()`.