---
title: "PickerState"
description: "A state object that can be hoisted to observe item selection.

In most cases, this will be created via [rememberPickerState]."
type: "class"
---

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


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

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


```kotlin
public class PickerState(
    @IntRange(from = 1) initialNumberOfOptions: Int,
    @IntRange(from = 0) initiallySelectedIndex: Int = 0,
    @get:Suppress("GetterSetterNames") public val shouldRepeatOptions: Boolean = true,
) : ScrollableState
```


A state object that can be hoisted to observe item selection.

In most cases, this will be created via `rememberPickerState`.

#### Parameters

| | |
| --- | --- |
| initialNumberOfOptions | the number of options. |
| initiallySelectedIndex | the index of the option to show in the center at the start, zero-based. |
| shouldRepeatOptions | if true (the default), the options will be repeated. |



## Functions

```kotlin
public suspend fun scrollToOption(index: Int)
```


Instantly scroll to an option.

#### Parameters

| | |
| --- | --- |
| index | The index of the option to scroll to. |



```kotlin
public suspend fun animateScrollToOption(index: Int)
```


Animate (smooth scroll) to the given option at `index`.

A smooth scroll always happens to the closest item if PickerState has repeatItems=true. For
example, picker values are : 0 1 2 3 0 1 2 `3` 0 1 2 3 Target value is `0`. 0 1 2 3 >0< 1 2
`3` >0< 1 2 3 Picker can be scrolled forwards or backwards. To get to the target 0 it
requires 1 step to scroll forwards and 3 steps to scroll backwards. Picker will be scrolled
forwards as this is the closest destination.

If the distance between possible targets is the same, picker will be scrolled backwards.

#### Parameters

| | |
| --- | --- |
| index | The index of the option to scroll to. |



## Companion Object

#### Properties

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


```kotlin
public val Saver: Saver<PickerState, Any>
```


The default `Saver` implementation for `PickerState`.





