# PaneExpansionState

Artifact: [androidx.compose.material3.adaptive:adaptive-layout](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/adaptive/layout/PaneExpansionState.kt+class:androidx.compose.material3.adaptive.layout.PaneExpansionState) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive#1.1.0) Common/All
- Cmn

  ```
  class PaneExpansionState
  ```

*** ** * ** ***

This class manages the pane expansion state for pane scaffolds. By providing and modifying an instance of this class, you can specify the expanded panes' expansion width or proportion when pane scaffold is displaying a dual-pane layout.

This class also serves as the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState` of pane expansion handle. When a handle implementation is provided to the associated pane scaffold, the scaffold will use `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState` to store and manage dragging and anchoring of the handle, and thus the pane expansion state.

## Summary

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#Unspecified()` The constant value used to denote the pane expansion is not specified. | Cmn |

| ### Public functions |
|---|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#animateTo(androidx.compose.material3.adaptive.layout.PaneExpansionAnchor,kotlin.Float)(anchor: https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionAnchor, initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Animate the pane expansion to the given `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionAnchor`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#clear()()` Clears any previously set `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneProportion()`, as well as the user dragging result. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#isUnspecified()()` Returns `true` if none of `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneProportion()` has been set. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneProportion(kotlin.Float)( firstPaneProportion: @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 )` Set the proportion of the first expanded pane in the layout. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneWidth(kotlin.Int)(firstPaneWidth: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the width of the first expanded pane in the layout. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionAnchor?` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#currentAnchor()` The current anchor that pane expansion has been settled or is settling to. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/SemanticsPropertyReceiver.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/ExperimentalMaterial3AdaptiveApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState.[defaultDragHandleSemantics](https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#(androidx.compose.material3.adaptive.layout.PaneExpansionState).defaultDragHandleSemantics())()` **This function is deprecated.** Just omit the semanticsProperties parameter when using Modifier.paneExpansionDraggable to set up the default semantics | Cmn |

## Constants

### Unspecified

Cmn

```
const val Unspecified: Int
```

The constant value used to denote the pane expansion is not specified.

## Public functions

### animateTo

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

```
suspend fun animateTo(anchor: PaneExpansionAnchor, initialVelocity: Float = 0.0f): Unit
```

Animate the pane expansion to the given `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionAnchor`. Note that the given anchor must be one of the provided anchor when creating the state with `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/rememberPaneExpansionState.composable#rememberPaneExpansionState(androidx.compose.material3.adaptive.layout.PaneExpansionStateKeyProvider,kotlin.collections.List,kotlin.Int,androidx.compose.animation.core.FiniteAnimationSpec,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Function1)`; otherwise the function throws.

| Parameters |
|---|---|
| `anchor: https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionAnchor` | the anchor to animate to |
| `initialVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | the initial velocity of the animation |

### clear

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

```
fun clear(): Unit
```

Clears any previously set `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneProportion()`, as well as the user dragging result.

### isUnspecified

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

```
fun isUnspecified(): Boolean
```

Returns `true` if none of `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneWidth()` or `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#firstPaneProportion()` has been set.

### setFirstPaneProportion

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

```
fun setFirstPaneProportion(
    firstPaneProportion: @FloatRange(from = 0.0, to = 1.0) Float
): Unit
```

Set the proportion of the first expanded pane in the layout. The set value needs to be within the range of `[0f, 1f]`, otherwise the setter throws.

Note that setting this value will reset the first pane width previously set via `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneWidth(kotlin.Int)` or the current dragging result if there's any. Also if user drags the pane after setting the first pane proportion, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.

### setFirstPaneWidth

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

```
fun setFirstPaneWidth(firstPaneWidth: Int): Unit
```

Set the width of the first expanded pane in the layout. When the set value gets applied, it will be coerced within the range of `[0, the full displayable width of the layout]`.

Note that setting this value will reset the first pane proportion previously set via `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneProportion(kotlin.Float)` or the current dragging result if there's any. Also if user drags the pane after setting the first pane width, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.

## Public properties

### currentAnchor

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

```
val currentAnchor: PaneExpansionAnchor?
```

The current anchor that pane expansion has been settled or is settling to. Note that this field might be `null` if:

1. No anchors have been set to the state.

2. Pane expansion is set directly via `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneWidth(kotlin.Int)` or set `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#setFirstPaneProportion(kotlin.Float)`.

3. Pane expansion is in its initial state without an initial anchor provided.

## Extension functions

### PaneExpansionState.defaultDragHandleSemantics

Cmn Artifact: [androidx.compose.material3.adaptive:adaptive-layout](https://developer.android.com/jetpack/androidx/releases/compose-material3-adaptive) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/adaptive/layout/PaneExpansionDraggableModifier.kt+function:defaultDragHandleSemantics)

```
@ExperimentalMaterial3AdaptiveApi
@Composable
fun PaneExpansionState.[defaultDragHandleSemantics](https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState#(androidx.compose.material3.adaptive.layout.PaneExpansionState).defaultDragHandleSemantics())(): SemanticsPropertyReceiver.() -> Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Just omit the semanticsProperties parameter when using Modifier.paneExpansionDraggable to set up the default semantics

This function sets up the default semantics of pane expansion drag handles with the given `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneExpansionState`. It will provide suitable `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/package-summary#(androidx.compose.ui.semantics.SemanticsPropertyReceiver).contentDescription()` as well as `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/package-summary#(androidx.compose.ui.semantics.SemanticsPropertyReceiver).onClick(kotlin.String,kotlin.Function0)` function to move the pane expansion among anchors that can be operated via accessibility services.

It's supposed to be used with a `https://developer.android.com/reference/kotlin/androidx/compose/material3/adaptive/layout/PaneScaffoldScope#(androidx.compose.ui.Modifier).paneExpansionDraggable(androidx.compose.material3.adaptive.layout.PaneExpansionState,androidx.compose.ui.unit.Dp,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function1)` modifier, or a plain `https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/semantics.modifier#(androidx.compose.ui.Modifier).semantics(kotlin.Boolean,kotlin.Function1)` modifier associated with a drag handle composable.