androidx.compose.material3

LargeFlexibleTopAppBarSince 1.10Experimental

Composable function

One of the top app bar types. It works like TopAppBar. Only the parameters that differ are described here.

An Expressive large bar. It can show a subtitle and center the title.

A large flexible top app bar with a subtitleExpressive theme
A large flexible top app bar with a subtitle
// Top app bars have the same color as the page. The border only shows where the bar ends.
val barOutline @Composable get() = Modifier.width(360.dp).border(1.dp, MaterialTheme.colorScheme.outlineVariant)

LargeFlexibleTopAppBar(
    title = { Text("Photos") },
    subtitle = { Text("1,204 items") },
    navigationIcon = { IconButton(onClick = {}) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back") } },
    modifier = barOutline,
)

ParametersExperimental

@Composable
fun LargeFlexibleTopAppBar(
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    subtitle: (@Composable () -> Unit)? = null,
    navigationIcon: @Composable () -> Unit = {},
    actions: @Composable RowScope.() -> Unit = {},
    titleHorizontalAlignment: Alignment.Horizontal = Alignment.Start,
    collapsedHeight: Dp = TopAppBarDefaults.LargeAppBarCollapsedHeight,
    expandedHeight: Dp = if (subtitle != null) { TopAppBarDefaults.LargeFlexibleAppBarWithSubtitleExpandedHeight } else { TopAppBarDefaults.LargeFlexibleAppBarWithoutSubtitleExpandedHeight },
    windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
    colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(),
    scrollBehavior: TopAppBarScrollBehavior? = null,
)

subtitle: (@Composable () -> Unit)?Optional

Default: null

A second, smaller line under the title.

Title and subtitle
Title and subtitle
TopAppBar(
    title = { Text("Trip to Lisbon") },
    subtitle = { Text("3 nights") },
    navigationIcon = {
        IconButton(onClick = {}) { Icon(Icons.Filled.Menu, "Menu") }
    },
    modifier = Modifier.width(360.dp),
)

collapsedHeight: DpOptional

Default: TopAppBarDefaults.LargeAppBarCollapsedHeight

The height of a medium or large bar after it shrinks.

Defaults that differ from TopAppBar:

Same as in TopAppBar: title, modifier, navigationIcon, actions, titleHorizontalAlignment, expandedHeight, windowInsets, colors, scrollBehavior.

Top app bar types

See also