TopAppBarDefaults


Contains default values used for the top app bar implementations.

Summary

Public functions

TopAppBarColors

Creates a TopAppBarColors for CenterAlignedTopAppBars.

Cmn
TopAppBarColors
@Composable
centerAlignedTopAppBarColors(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color
)

Creates a TopAppBarColors for CenterAlignedTopAppBars.

Cmn
TopAppBarScrollBehavior
@ExperimentalMaterial3Api
@Composable
enterAlwaysScrollBehavior(
    state: TopAppBarState,
    canScroll: () -> Boolean,
    snapAnimationSpec: AnimationSpec<Float>?,
    flingAnimationSpec: DecayAnimationSpec<Float>?
)

Returns a TopAppBarScrollBehavior.

Cmn
TopAppBarScrollBehavior
@ExperimentalMaterial3Api
@Composable
exitUntilCollapsedScrollBehavior(
    state: TopAppBarState,
    canScroll: () -> Boolean,
    snapAnimationSpec: AnimationSpec<Float>?,
    flingAnimationSpec: DecayAnimationSpec<Float>?
)

Returns a TopAppBarScrollBehavior that adjusts its properties to affect the colors and height of the top app bar.

Cmn
TopAppBarColors

Creates a TopAppBarColors for LargeTopAppBars.

Cmn
TopAppBarColors
@Composable
largeTopAppBarColors(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color
)

Creates a TopAppBarColors for LargeTopAppBars.

Cmn
TopAppBarColors

Creates a TopAppBarColors for MediumTopAppBars.

Cmn
TopAppBarColors
@Composable
mediumTopAppBarColors(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color
)

Creates a TopAppBarColors for MediumTopAppBars.

Cmn
TopAppBarScrollBehavior

Returns a pinned TopAppBarScrollBehavior that tracks nested-scroll callbacks and updates its TopAppBarState.contentOffset accordingly.

Cmn
TopAppBarColors
@Composable
smallTopAppBarColors(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color
)

This function is deprecated. Use topAppBarColors instead.

Cmn
TopAppBarColors

Creates a TopAppBarColors for small TopAppBar.

Cmn
TopAppBarColors
@Composable
topAppBarColors(
    containerColor: Color,
    scrolledContainerColor: Color,
    navigationIconContentColor: Color,
    titleContentColor: Color,
    actionIconContentColor: Color
)

Creates a TopAppBarColors for small TopAppBar.

Cmn

Public properties

WindowInsets

Default insets to be used and consumed by the top app bars

Cmn

Public functions

centerAlignedTopAppBarColors

@Composable
fun centerAlignedTopAppBarColors(): TopAppBarColors

Creates a TopAppBarColors for CenterAlignedTopAppBars. The default implementation animates between the provided colors according to the Material Design specification.

centerAlignedTopAppBarColors

@Composable
fun centerAlignedTopAppBarColors(
    containerColor: Color = Color.Unspecified,
    scrolledContainerColor: Color = Color.Unspecified,
    navigationIconContentColor: Color = Color.Unspecified,
    titleContentColor: Color = Color.Unspecified,
    actionIconContentColor: Color = Color.Unspecified
): TopAppBarColors

Creates a TopAppBarColors for CenterAlignedTopAppBars. The default implementation animates between the provided colors according to the Material Design specification.

Parameters
containerColor: Color = Color.Unspecified

the container color

scrolledContainerColor: Color = Color.Unspecified

the container color when content is scrolled behind it

navigationIconContentColor: Color = Color.Unspecified

the content color used for the navigation icon

titleContentColor: Color = Color.Unspecified

the content color used for the title

actionIconContentColor: Color = Color.Unspecified

the content color used for actions

Returns
TopAppBarColors

the resulting TopAppBarColors used for the top app bar

enterAlwaysScrollBehavior

@ExperimentalMaterial3Api
@Composable
fun enterAlwaysScrollBehavior(
    state: TopAppBarState = rememberTopAppBarState(),
    canScroll: () -> Boolean = { true },
    snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow),
    flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()
): TopAppBarScrollBehavior

Returns a TopAppBarScrollBehavior. A top app bar that is set up with this TopAppBarScrollBehavior will immediately collapse when the content is pulled up, and will immediately appear when the content is pulled down.

Parameters
state: TopAppBarState = rememberTopAppBarState()

the state object to be used to control or observe the top app bar's scroll state. See rememberTopAppBarState for a state that is remembered across compositions.

canScroll: () -> Boolean = { true }

a callback used to determine whether scroll events are to be handled by this EnterAlwaysScrollBehavior

snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow)

an optional AnimationSpec that defines how the top app bar snaps to either fully collapsed or fully extended state when a fling or a drag scrolled it into an intermediate position

flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()

an optional DecayAnimationSpec that defined how to fling the top app bar when the user flings the app bar itself, or the content below it

exitUntilCollapsedScrollBehavior

@ExperimentalMaterial3Api
@Composable
fun exitUntilCollapsedScrollBehavior(
    state: TopAppBarState = rememberTopAppBarState(),
    canScroll: () -> Boolean = { true },
    snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow),
    flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()
): TopAppBarScrollBehavior

Returns a TopAppBarScrollBehavior that adjusts its properties to affect the colors and height of the top app bar.

A top app bar that is set up with this TopAppBarScrollBehavior will immediately collapse when the nested content is pulled up, and will expand back the collapsed area when the content is pulled all the way down.

Parameters
state: TopAppBarState = rememberTopAppBarState()

the state object to be used to control or observe the top app bar's scroll state. See rememberTopAppBarState for a state that is remembered across compositions.

canScroll: () -> Boolean = { true }

a callback used to determine whether scroll events are to be handled by this ExitUntilCollapsedScrollBehavior

snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow)

an optional AnimationSpec that defines how the top app bar snaps to either fully collapsed or fully extended state when a fling or a drag scrolled it into an intermediate position

flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()

an optional DecayAnimationSpec that defined how to fling the top app bar when the user flings the app bar itself, or the content below it

largeTopAppBarColors

@Composable
fun largeTopAppBarColors(): TopAppBarColors

Creates a TopAppBarColors for LargeTopAppBars. The default implementation interpolates between the provided colors as the top app bar scrolls according to the Material Design specification.

largeTopAppBarColors

@Composable
fun largeTopAppBarColors(
    containerColor: Color = Color.Unspecified,
    scrolledContainerColor: Color = Color.Unspecified,
    navigationIconContentColor: Color = Color.Unspecified,
    titleContentColor: Color = Color.Unspecified,
    actionIconContentColor: Color = Color.Unspecified
): TopAppBarColors

Creates a TopAppBarColors for LargeTopAppBars. The default implementation interpolates between the provided colors as the top app bar scrolls according to the Material Design specification.

Parameters
containerColor: Color = Color.Unspecified

the container color

scrolledContainerColor: Color = Color.Unspecified

the container color when content is scrolled behind it

navigationIconContentColor: Color = Color.Unspecified

the content color used for the navigation icon

titleContentColor: Color = Color.Unspecified

the content color used for the title

actionIconContentColor: Color = Color.Unspecified

the content color used for actions

Returns
TopAppBarColors

the resulting TopAppBarColors used for the top app bar

mediumTopAppBarColors

@Composable
fun mediumTopAppBarColors(): TopAppBarColors

Creates a TopAppBarColors for MediumTopAppBars. The default implementation interpolates between the provided colors as the top app bar scrolls according to the Material Design specification.

mediumTopAppBarColors

@Composable
fun mediumTopAppBarColors(
    containerColor: Color = Color.Unspecified,
    scrolledContainerColor: Color = Color.Unspecified,
    navigationIconContentColor: Color = Color.Unspecified,
    titleContentColor: Color = Color.Unspecified,
    actionIconContentColor: Color = Color.Unspecified
): TopAppBarColors

Creates a TopAppBarColors for MediumTopAppBars. The default implementation interpolates between the provided colors as the top app bar scrolls according to the Material Design specification.

Parameters
containerColor: Color = Color.Unspecified

the container color

scrolledContainerColor: Color = Color.Unspecified

the container color when content is scrolled behind it

navigationIconContentColor: Color = Color.Unspecified

the content color used for the navigation icon

titleContentColor: Color = Color.Unspecified

the content color used for the title

actionIconContentColor: Color = Color.Unspecified

the content color used for actions

Returns
TopAppBarColors

the resulting TopAppBarColors used for the top app bar

pinnedScrollBehavior

@ExperimentalMaterial3Api
@Composable
fun pinnedScrollBehavior(
    state: TopAppBarState = rememberTopAppBarState(),
    canScroll: () -> Boolean = { true }
): TopAppBarScrollBehavior

Returns a pinned TopAppBarScrollBehavior that tracks nested-scroll callbacks and updates its TopAppBarState.contentOffset accordingly.

Parameters
state: TopAppBarState = rememberTopAppBarState()

the state object to be used to control or observe the top app bar's scroll state. See rememberTopAppBarState for a state that is remembered across compositions.

canScroll: () -> Boolean = { true }

a callback used to determine whether scroll events are to be handled by this pinned TopAppBarScrollBehavior

smallTopAppBarColors

@Composable
fun smallTopAppBarColors(
    containerColor: Color = TopAppBarSmallTokens.ContainerColor.value,
    scrolledContainerColor: Color = TopAppBarSmallTokens.OnScrollContainerColor.value,
    navigationIconContentColor: Color = TopAppBarSmallTokens.LeadingIconColor.value,
    titleContentColor: Color = TopAppBarSmallTokens.HeadlineColor.value,
    actionIconContentColor: Color = TopAppBarSmallTokens.TrailingIconColor.value
): TopAppBarColors

Creates a TopAppBarColors for small TopAppBars. The default implementation animates between the provided colors according to the Material Design specification.

use topAppBarColors instead

Parameters
containerColor: Color = TopAppBarSmallTokens.ContainerColor.value

the container color

scrolledContainerColor: Color = TopAppBarSmallTokens.OnScrollContainerColor.value

the container color when content is scrolled behind it

navigationIconContentColor: Color = TopAppBarSmallTokens.LeadingIconColor.value

the content color used for the navigation icon

titleContentColor: Color = TopAppBarSmallTokens.HeadlineColor.value

the content color used for the title

actionIconContentColor: Color = TopAppBarSmallTokens.TrailingIconColor.value

the content color used for actions

Returns
TopAppBarColors

the resulting TopAppBarColors used for the top app bar

topAppBarColors

@Composable
fun topAppBarColors(): TopAppBarColors

Creates a TopAppBarColors for small TopAppBar. The default implementation animates between the provided colors according to the Material Design specification.

topAppBarColors

@Composable
fun topAppBarColors(
    containerColor: Color = Color.Unspecified,
    scrolledContainerColor: Color = Color.Unspecified,
    navigationIconContentColor: Color = Color.Unspecified,
    titleContentColor: Color = Color.Unspecified,
    actionIconContentColor: Color = Color.Unspecified
): TopAppBarColors

Creates a TopAppBarColors for small TopAppBar. The default implementation animates between the provided colors according to the Material Design specification.

Parameters
containerColor: Color = Color.Unspecified

the container color

scrolledContainerColor: Color = Color.Unspecified

the container color when content is scrolled behind it

navigationIconContentColor: Color = Color.Unspecified

the content color used for the navigation icon

titleContentColor: Color = Color.Unspecified

the content color used for the title

actionIconContentColor: Color = Color.Unspecified

the content color used for actions

Returns
TopAppBarColors

the resulting TopAppBarColors used for the top app bar

Public properties

windowInsets

val windowInsetsWindowInsets

Default insets to be used and consumed by the top app bars