---
title: "SwipeableState"
description: "State of the [swipeable] modifier.

This contains necessary information about any ongoing swipe or animation and provides methods to
change the state either immediately or by starting an animation. To create and remember a
[SwipeableState] with the default animation clock, use [rememberSwipeableState]."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>


```kotlin
@ExperimentalWearMaterialApi
public open class SwipeableState<T>(
    internal val initialValue: T,
    internal val animationSpec: AnimationSpec<Float> = SwipeableDefaults.AnimationSpec,
    internal val confirmStateChange: (newValue: T) -> Boolean = { true },
)
```


State of the `swipeable` modifier.

This contains necessary information about any ongoing swipe or animation and provides methods to
change the state either immediately or by starting an animation. To create and remember a
`SwipeableState` with the default animation clock, use `rememberSwipeableState`.

#### Parameters

| | |
| --- | --- |
| initialValue | The initial value of the state. |
| animationSpec | The default animation that will be used to animate to a new state. |
| confirmStateChange | Optional callback invoked to confirm or veto a pending state change. If the state change is accepted, the offset is optionally be reset to the initial value. and offset is reset. |



## Functions

```kotlin
@ExperimentalWearMaterialApi
    public suspend fun snapTo(targetValue: T)
```


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

#### Parameters

| | |
| --- | --- |
| targetValue | The new target value to set `currentValue` to. |



```kotlin
@ExperimentalWearMaterialApi
    public suspend fun animateTo(targetValue: T, anim: AnimationSpec<Float> = animationSpec)
```


Set the state to the target value by starting an animation.

#### Parameters

| | |
| --- | --- |
| targetValue | The new value to animate to. |
| anim | The animation that will be used to animate to the new value. |



```kotlin
@ExperimentalWearMaterialApi
    public suspend fun performFling(velocity: Float)
```


Perform fling with settling to one of the anchors which is determined by the given
`velocity`. Fling with settling `swipeable` will always consume all the velocity provided
since it will settle at the anchor.

In general cases, `swipeable` flings by itself when being swiped. This method is to be used
for nested scroll logic that wraps the `swipeable`. In nested scroll developer may want to
trigger settling fling when the child scroll container reaches the bound.

#### Parameters

| | |
| --- | --- |
| velocity | velocity to fling and settle with |


#### Returns

| | |
| --- | --- |
|  | the reason fling ended |



## Companion Object

#### Methods

<div class='sourceset sourceset-android'>Android</div>


```kotlin
public fun <T : Any> Saver(
            animationSpec: AnimationSpec<Float>,
            confirmStateChange: (T) -> Boolean,
        ): Saver<SwipeableState<T>, T>
```


The default `Saver` implementation for `SwipeableState`.





