# TopAppBarState

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

  ```
  class TopAppBarState
  ```

*** ** * ** ***

A state object that can be hoisted to control and observe the top app bar state. The state is read and updated by a `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarScrollBehavior` implementation.

In most cases, this state will be created via `https://developer.android.com/reference/kotlin/androidx/compose/material3/rememberTopAppBarState.composable#rememberTopAppBarState(kotlin.Float,kotlin.Float,kotlin.Float)`.

## Summary

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState, *>` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#Saver()` The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState`. | Cmn |

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#TopAppBarState(kotlin.Float,kotlin.Float,kotlin.Float)( initialHeightOffsetLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialHeightOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, initialContentOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#collapsedFraction()` A value that represents the collapsed height percentage of the app bar. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#contentOffset()` The total offset of the content scrolled under the top app bar. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffset()` The top app bar's current height offset in pixels. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffsetLimit()` The top app bar's height offset limit in pixels, which represents the limit that a top app bar is allowed to collapse to. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#overlappedFraction()` A value that represents the percentage of the app bar area that is overlapping with the content scrolled behind it. | Cmn |

## Public companion properties

### Saver

Cmn

```
val Saver: Saver<TopAppBarState, *>
```

The default `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState`.

## Public constructors

### TopAppBarState

Cmn

```
TopAppBarState(
    initialHeightOffsetLimit: Float,
    initialHeightOffset: Float,
    initialContentOffset: Float
)
```

| Parameters |
|---|---|
| `initialHeightOffsetLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffsetLimit()` |
| `initialHeightOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffset()` |
| `initialContentOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#contentOffset()` |

## Public properties

### collapsedFraction

Cmn

```
val collapsedFraction: Float
```

A value that represents the collapsed height percentage of the app bar.

A `0.0` represents a fully expanded bar, and `1.0` represents a fully collapsed bar (computed as `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffset()` / `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffsetLimit()`).

### contentOffset

Cmn

```
var contentOffset: Float
```

The total offset of the content scrolled under the top app bar.

The content offset is used to compute the `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#overlappedFraction()`, which can later be read by an implementation.

This value is updated by a `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarScrollBehavior` whenever a nested scroll connection consumes scroll events. A common implementation would update the value to be the sum of all `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/nestedscroll/NestedScrollConnection#onPostScroll(androidx.compose.ui.geometry.Offset,androidx.compose.ui.geometry.Offset,androidx.compose.ui.input.nestedscroll.NestedScrollSource)` `consumed.y` values.

### heightOffset

Cmn

```
var heightOffset: Float
```

The top app bar's current height offset in pixels. This height offset is applied to the fixed height of the app bar to control the displayed height when content is being scrolled.

Updates to the `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffset()` value are coerced between zero and `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffsetLimit()`.

### heightOffsetLimit

Cmn

```
var heightOffsetLimit: Float
```

The top app bar's height offset limit in pixels, which represents the limit that a top app bar is allowed to collapse to.

Use this limit to coerce the `https://developer.android.com/reference/kotlin/androidx/compose/material3/TopAppBarState#heightOffset()` value when it's updated.

### overlappedFraction

Cmn

```
val overlappedFraction: Float
```

A value that represents the percentage of the app bar area that is overlapping with the content scrolled behind it.

A `0.0` indicates that the app bar does not overlap any content, while `1.0` indicates that the entire visible app bar area overlaps the scrolled content.