# SearchBarState

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/SearchBar.kt+class:androidx.compose.material3.SearchBarState) Common/AllAndroid/JVM
- Cmn

  ```
  class SearchBarState
  ```

*** ** * ** ***

The state of a search bar.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)( animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> )` The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)( animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForContentFadeIn: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForContentFadeOut: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> )` The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#SearchBarState(androidx.compose.material3.SearchBarValue,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)( initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue, animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> )` Construct a `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#SearchBarState(androidx.compose.material3.SearchBarValue,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)( initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue, animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForContentFadeIn: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>, animationSpecForContentFadeOut: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html> )` Construct a `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`. | Cmn |

| ### Public functions |
|---|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#animateToCollapsed()()` Animate the search bar to its collapsed state. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#animateToExpanded()()` Animate the search bar to its expanded state. | Cmn |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#snapTo(kotlin.Float)(fraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Snap the search bar progress to the given `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#snapTo(kotlin.Float)`, where 0 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Collapsed` and 1 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Expanded`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#currentValue()` Whether the search bar is currently expanded or collapsed. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#isAnimating()` Whether the state is currently animating | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#progress()` The animation progress of the search bar, where 0 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Collapsed` and 1 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Expanded`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#targetValue()` Whether the search bar is going to be expanded or collapsed. | Cmn |

## Public companion functions

### Saver

Cmn

```
fun Saver(
    animationSpecForExpand: AnimationSpec<Float>,
    animationSpecForCollapse: AnimationSpec<Float>
): Saver<SearchBarState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`.

### Saver

Cmn

```
fun Saver(
    animationSpecForExpand: AnimationSpec<Float>,
    animationSpecForCollapse: AnimationSpec<Float>,
    animationSpecForContentFadeIn: AnimationSpec<Float>,
    animationSpecForContentFadeOut: AnimationSpec<Float>
): Saver<SearchBarState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#Saver(androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec,androidx.compose.animation.core.AnimationSpec)` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`.

## Public constructors

### SearchBarState

Cmn

```
SearchBarState(
    initialValue: SearchBarValue,
    animationSpecForExpand: AnimationSpec<Float>,
    animationSpecForCollapse: AnimationSpec<Float>
)
```

Construct a `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`.

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue` | the initial value of whether the search bar is collapsed or expanded. |
| `animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used when the search bar expands. |
| `animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used when the search bar collapses. |

### SearchBarState

Cmn

```
SearchBarState(
    initialValue: SearchBarValue,
    animationSpecForExpand: AnimationSpec<Float>,
    animationSpecForCollapse: AnimationSpec<Float>,
    animationSpecForContentFadeIn: AnimationSpec<Float>,
    animationSpecForContentFadeOut: AnimationSpec<Float>
)
```

Construct a `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState`.

| Parameters |
|---|---|
| `initialValue: https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue` | the initial value of whether the search bar is collapsed or expanded. |
| `animationSpecForExpand: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used when the search bar expands. |
| `animationSpecForCollapse: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used when the search bar collapses. |
| `animationSpecForContentFadeIn: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used for the content when the search bar expands. |
| `animationSpecForContentFadeOut: https://developer.android.com/reference/kotlin/androidx/compose/animation/core/AnimationSpec<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | the animation spec used for the content when the search bar collapses. |

## Public functions

### animateToCollapsed

Cmn

```
suspend fun animateToCollapsed(): Unit
```

Animate the search bar to its collapsed state.

### animateToExpanded

Cmn

```
suspend fun animateToExpanded(): Unit
```

Animate the search bar to its expanded state.

### snapTo

Cmn

```
suspend fun snapTo(fraction: Float): Unit
```

Snap the search bar progress to the given `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#snapTo(kotlin.Float)`, where 0 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Collapsed` and 1 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Expanded`.

## Public properties

### currentValue

Cmn

```
val currentValue: SearchBarValue
```

Whether the search bar is currently expanded or collapsed. If the search bar is currently animating to/from the expanded state, `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarState#currentValue()` is `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Expanded` until the animation completes.

### isAnimating

Cmn

```
val isAnimating: Boolean
```

Whether the state is currently animating

### progress

Cmn

```
val progress: Float
```

The animation progress of the search bar, where 0 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Collapsed` and 1 represents `https://developer.android.com/reference/kotlin/androidx/compose/material3/SearchBarValue#Expanded`.

### targetValue

Cmn

```
val targetValue: SearchBarValue
```

Whether the search bar is going to be expanded or collapsed.