---
title: "rememberSearchBarWithGapState"
description: "Create and remember a SearchBarState to use in conjunction with ExpandedDockedSearchBarWithGap."
type: "composable"
lastmod: "2026-04-23T11:19:39.030449Z"
---
## API Reference

### rememberSearchBarWithGapState

> Source set: Common

```kotlin
@ExperimentalMaterial3Api
@Composable
fun rememberSearchBarWithGapState(
    initialValue: SearchBarValue = SearchBarValue.Collapsed,
    animationSpecForExpand: AnimationSpec<Float> = MotionSchemeKeyTokens.DefaultSpatial.value(),
    animationSpecForCollapse: AnimationSpec<Float> = MotionSchemeKeyTokens.FastSpatial.value(),
    animationSpecForContentFadeIn: AnimationSpec<Float> = AnimationForContentFadeInSpec,
    animationSpecForContentFadeOut: AnimationSpec<Float> = AnimationForContentFadeOutSpec,
): SearchBarState
```

Create and remember a [SearchBarState](/jetpack-compose/androidx.compose.material3/material3/classes/SearchBarState) to use in conjunction with
[ExpandedDockedSearchBarWithGap](/jetpack-compose/androidx.compose.material3/material3/components/ExpandedDockedSearchBarWithGap).

#### 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. |
| animationSpecForContentFadeIn | the animation spec used for the content when the search bar expands. |
| animationSpecForContentFadeOut | the animation spec used for the content when the search bar collapses. |
