---
title: "SearchBarScrollState"
description: "A state object that can be hoisted to control and observe the search bar's scroll state."
type: "class"
---
## API Reference

> Source set: Common

```kotlin
public class SearchBarScrollState(
    initialScrollOffsetLimit: Float,
    initialScrollOffset: Float,
    initialContentOffset: Float,
)
```

A state object that can be hoisted to control and observe the search bar's scroll state. The
state is read and updated by a [SearchBarScrollBehavior](/jetpack-compose/androidx.compose.material3/material3/interfaces/SearchBarScrollBehavior/api) implementation.

In most cases, this state will be created via [rememberSearchBarScrollState](/jetpack-compose/androidx.compose.material3/material3/composable-functions/rememberSearchBarScrollState/api).

#### Parameters

| | |
| --- | --- |
| initialScrollOffsetLimit | the initial value for [SearchBarScrollState.scrollOffsetLimit](/jetpack-compose/androidx.compose.material3/material3/classes/SearchBarScrollState) |
| initialScrollOffset | the initial value for [SearchBarScrollState.scrollOffset](/jetpack-compose/androidx.compose.material3/material3/classes/SearchBarScrollState) |
| initialContentOffset | the initial value for [SearchBarScrollState.contentOffset](/jetpack-compose/androidx.compose.material3/material3/classes/SearchBarScrollState) |

## Properties

### scrollOffset

> Source set: Common

```kotlin
public var scrollOffset: Float
```

The search bar's current offset due to scrolling, in pixels. This offset is applied to the
fixed size of the search bar to control the displayed size when content is being scrolled.

This value is typically negative.

Updates to the `scrollOffset` value are coerced between `scrollOffsetLimit` and 0.

### scrollOffsetLimit

> Source set: Common

```kotlin
public var scrollOffsetLimit: Float by mutableFloatStateOf(initialScrollOffsetLimit)
```

The limit that a search bar can be offset due to scrolling, in pixels.

This value is typically negative.

Use this limit to coerce the `scrollOffset` value when it's updated.

### contentOffset

> Source set: Common

```kotlin
public var contentOffset: Float by mutableFloatStateOf(initialContentOffset)
```

The total offset of the content scrolled under the search bar.

The content offset is used to compute the `overlappedFraction`, which can later be read by an
implementation.

This value is updated by a [SearchBarScrollBehavior](/jetpack-compose/androidx.compose.material3/material3/interfaces/SearchBarScrollBehavior/api) whenever a nested scroll connection
consumes scroll events. A common implementation would update the value to be the sum of all
`NestedScrollConnection.onPostScroll` `consumed.y` values.

## Members

### Companion

> Source set: Common

```kotlin
public companion object
```

## Properties

### Saver

> Source set: Common

```kotlin
public val Saver: Saver<SearchBarScrollState, *> =
            listSaver(
                save = { listOf(it.scrollOffsetLimit, it.scrollOffset, it.contentOffset) },
                restore = {
                    SearchBarScrollState(
                        initialScrollOffsetLimit = it[0],
                        initialScrollOffset = it[1],
                        initialContentOffset = it[2],
                    )
                },
            )
```

The default `Saver` implementation for [SearchBarScrollState](/jetpack-compose/androidx.compose.material3/material3/classes/SearchBarScrollState/api).
