# SliderState

Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/Slider.kt+class:androidx.compose.material3.SliderState) Common/AllAndroid/JVM
- Cmn

  ```
  class SliderState : DraggableState
  ```

*** ** * ** ***

Class that holds information about `https://developer.android.com/reference/kotlin/androidx/compose/material3/Slider.composable#Slider(kotlin.Float,kotlin.Function1,androidx.compose.ui.Modifier,kotlin.Boolean,kotlin.ranges.ClosedFloatingPointRange,kotlin.Int,kotlin.Function0,androidx.compose.material3.SliderColors,androidx.compose.foundation.interaction.MutableInteractionSource)`'s active range.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#Saver(kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)(steps: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-closed-floating-point-range/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>)` The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#Saver(kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState`. | Cmn |

| ### Public constructors |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/annotation/RememberInComposition https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#SliderState(kotlin.Float,kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)( value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, steps: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, trackRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-closed-floating-point-range/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> )` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#dispatchRawDelta(kotlin.Float)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Dispatch drag delta in pixels avoiding all drag related priority mechanisms. | Cmn |
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)(dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Call this function to take control of drag logic. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#coercedValueAsFraction()` The fraction of the track that the thumb currently occupies. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#isDragging()` Indicates whether the slider is currently being dragged. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#shouldAutoSnap()` Controls the auto-snapping mechanism for slider steps. | Cmn |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()` if positive, specifies the amount of discrete allowable values between the endpoints of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-closed-floating-point-range/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()` range of values that Slider values can take. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#value()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` that indicates the value that the thumb currently is in respect to the track. | Cmn |

## Public companion functions

### Saver

Cmn

```
fun Saver(steps: Int, trackRange: ClosedFloatingPointRange<Float>): Saver<SliderState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#Saver(kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState`.

| Parameters |
|---|---|
| `steps: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | if positive, specifies the amount of discrete allowable values between the endpoints of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState.Companion#Saver(kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)`. |
| `trackRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-closed-floating-point-range/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | range of values that Slider values can take. `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#value()` will be coerced to this range. |

## Public constructors

### SliderState

Cmn

```
@RememberInComposition
SliderState(
    value: Float = 0.0f,
    steps: @IntRange(from = 0) Int = 0,
    trackRange: ClosedFloatingPointRange<Float> = 0f..1f
)
```

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` that indicates the initial position of the thumb. If outside of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()` provided, value will be coerced to this range. |
| `steps: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | if positive, specifies the amount of discrete allowable values between the endpoints of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()`. For example, a range from 0 to 10 with 4 `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()` allows 4 values evenly distributed between 0 and 10 (i.e., 2, 4, 6, 8). If `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()` is 0, the slider will behave continuously and allow any value from the range. Must not be negative. |
| `trackRange: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.ranges/-closed-floating-point-range/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> = 0f..1f` | range of values that Slider values can take. `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#(kotlin.Float,kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)` will be coerced to this range. |

## Public functions

### dispatchRawDelta

Cmn

```
open fun dispatchRawDelta(delta: Float): Unit
```

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

**NOTE:** unlike `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)`, dispatching any delta with this method will bypass scrolling of any priority. This method will also ignore `reverseDirection` and other parameters set in `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/draggable.modifier#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean)`.

This method is used internally for low level operations, allowing implementers of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState` influence the consumption as suits them, e.g. introduce nested scrolling. Manually dispatching delta via this method will likely result in a bad user experience, you must prefer `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` method over this one.

| Parameters |
|---|---|
| `delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | amount of scroll dispatched in the nested drag process |

### drag

Cmn

```
open suspend fun drag(
    dragPriority: MutatePriority = MutatePriority.Default,
    block: suspend DragScope.() -> Unit
): Unit
```

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.

If `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` is called from elsewhere with the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DraggableState#drag(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)` higher or equal to ongoing drag, ongoing drag will be canceled.

| Parameters |
|---|---|
| `dragPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority = MutatePriority.Default` | of the drag operation |
| `block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/DragScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | to perform drag in |

## Public properties

### coercedValueAsFraction

Cmn

```
val coercedValueAsFraction: Float
```

The fraction of the track that the thumb currently occupies.

The value is coerced (clamped) to the bounds of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()` before calculating its fractional position (from `0f` to `1f`) on the track.

### isDragging

Cmn

```
val isDragging: Boolean
```

Indicates whether the slider is currently being dragged.

This is set to `true` when a drag gesture starts (either via user touch interaction or programmatically via `drag`) and set back to `false` when the gesture completes or is cancelled.

### shouldAutoSnap

Cmn

```
var shouldAutoSnap: Boolean
```

Controls the auto-snapping mechanism for slider steps.

When `true` (default), any updates to `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#value()` will automatically snap to the nearest tick fraction based on the number of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()`.

Disabling auto-snapping (`false`) allows `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#value()` to be set to any continuous value between `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()` without snapping. This is particularly useful for programmatic animations, smooth transitions, or custom drag gestures where discrete step snapping is temporarily or permanently undesired.

Since this is defined on the state, it can be dynamically toggled during gestures or animations without triggering a full layout recomposition.

### steps

Cmn

```
val steps: @IntRange(from = 0) Int
```

if positive, specifies the amount of discrete allowable values between the endpoints of `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#trackRange()`. For example, a range from 0 to 10 with 4 `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()` allows 4 values evenly distributed between 0 and 10 (i.e., 2, 4, 6, 8). If `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#steps()` is 0, the slider will behave continuously and allow any value from the range. Must not be negative.

### trackRange

Cmn

```
val trackRange: ClosedFloatingPointRange<Float>
```

range of values that Slider values can take. `https://developer.android.com/reference/kotlin/androidx/compose/material3/SliderState#(kotlin.Float,kotlin.Int,kotlin.ranges.ClosedFloatingPointRange)` will be coerced to this range.

### value

Cmn

```
var value: Float
```

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` that indicates the value that the thumb currently is in respect to the track.