---
title: "rememberSearchBarState"
description: "Create and remember a [SearchBarState]."
type: "composable"
---

<div class='type'>Composable Function</div>


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

<div class='sourceset sourceset-common'>Common</div>


```kotlin
@ExperimentalMaterial3Api
@Composable
fun rememberSearchBarState(
    initialValue: SearchBarValue = SearchBarValue.Collapsed,
    animationSpecForExpand: AnimationSpec<Float> = MotionSchemeKeyTokens.SlowSpatial.value(),
    animationSpecForCollapse: AnimationSpec<Float> = MotionSchemeKeyTokens.DefaultSpatial.value(),
): SearchBarState
```


Create and remember a `SearchBarState`.

#### Parameters

| | |
| --- | --- |
| initialValue | the initial value of whether the search bar is collapsed or expanded. |
| animationSpecForExpand | the animation spec used when the search bar expands. |
| animationSpecForCollapse | the animation spec used when the search bar collapses. |





