androidx.compose.material3
TopAppBar
Composable function
A top app bar shows the title of the screen, a navigation button on the left, and actions on the right.
Put it in the topBar slot of a Scaffold.

TopAppBar(
title = { Text("Inbox") },
navigationIcon = {
IconButton(onClick = {}) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back") }
},
actions = {
IconButton(onClick = {}) { Icon(Icons.Filled.Search, "Search") }
IconButton(onClick = {}) { Icon(Icons.Filled.MoreVert, "More") }
},
modifier = Modifier.width(360.dp),
)
There are four basic types. Medium and large bars start tall and can shrink to the small size while the user scrolls. See Top app bar types.

// The outline only shows the size of each bar. Bars have the page color.
val outline = Modifier.border(1.dp, MaterialTheme.colorScheme.outlineVariant)
Column(Modifier.width(360.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {
TopAppBar(title = { Text("Small") }, modifier = outline)
CenterAlignedTopAppBar(title = { Text("Center-aligned") }, modifier = outline)
MediumTopAppBar(title = { Text("Medium") }, modifier = outline)
LargeTopAppBar(title = { Text("Large") }, modifier = outline)
}
Expressive adds flexible medium and large bars, with an optional subtitle and centered title.

MediumFlexibleTopAppBar(
title = { Text("Photos") },
subtitle = { Text("1,204 items") },
navigationIcon = {
IconButton(onClick = {}) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "Back") }
},
// The outline only shows the size of the bar.
modifier = Modifier.width(360.dp).border(1.dp, MaterialTheme.colorScheme.outlineVariant),
)
Basic
A title, with optional navigation icon and actions.
@Composable
fun TopAppBar(
title: @Composable () -> Unit,
modifier: Modifier = Modifier,
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
expandedHeight: Dp = TopAppBarDefaults.TopAppBarExpandedHeight,
windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(),
scrollBehavior: TopAppBarScrollBehavior? = null,
contentPadding: PaddingValues = TopAppBarDefaults.ContentPadding,
)
title: @Composable () -> UnitRequired
title: @Composable () -> UnitRequiredThe title of the screen. Usually one Text. Long titles are cut off with "…".
modifier: ModifierOptional
modifier: ModifierOptionalDefault: Modifier
Changes size, padding, or position of the bar. See the Modifier guide.
navigationIcon: @Composable () -> UnitOptional
navigationIcon: @Composable () -> UnitOptionalDefault: {}
A button at the start of the bar, usually back or menu. Use an IconButton.
actions: @Composable RowScope.() -> UnitOptional
actions: @Composable RowScope.() -> UnitOptionalDefault: {}
Buttons at the end of the bar. Use IconButtons. Put rare actions in an overflow menu behind a "more" icon.
Items are placed in a Row.
expandedHeight: DpOptional
expandedHeight: DpOptionalDefault: TopAppBarDefaults.TopAppBarExpandedHeight
The height of the bar. For medium and large bars, the height before shrinking.
windowInsets: WindowInsetsOptional
windowInsets: WindowInsetsOptionalDefault: TopAppBarDefaults.windowInsets
Space kept free for system bars, like the status bar on phones. The default is usually right.
colors: TopAppBarColorsOptional
colors: TopAppBarColorsOptionalDefault: TopAppBarDefaults.topAppBarColors()
Sets the background, title and icon colors, and the background while content scrolls under the bar.
Make one with TopAppBarDefaults.topAppBarColors.

TopAppBar(
title = { Text("Settings") },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.onPrimaryContainer,
),
modifier = Modifier.width(360.dp),
)
scrollBehavior: TopAppBarScrollBehavior?Optional
scrollBehavior: TopAppBarScrollBehavior?OptionalDefault: null
How the bar reacts when the content scrolls. Default: it does not move.
Get one from TopAppBarDefaults:
pinnedScrollBehavior(): stays put, changes color.enterAlwaysScrollBehavior(): hides when scrolling down, comes back when scrolling up.exitUntilCollapsedScrollBehavior(): medium and large bars shrink to the small size.
You must also connect the scrolling content: add Modifier.nestedScroll(scrollBehavior.nestedScrollConnection) to the Scaffold.
contentPadding: PaddingValuesOptionalSince 1.10
contentPadding: PaddingValuesOptionalSince 1.10Default: TopAppBarDefaults.ContentPadding
Space between the edge of the bar and its content.
With subtitleExperimental
Adds a subtitle below the title.
@Composable
fun TopAppBar(
title: @Composable () -> Unit,
subtitle: @Composable () -> Unit,
modifier: Modifier = Modifier,
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
titleHorizontalAlignment: Alignment.Horizontal = Alignment.Start,
expandedHeight: Dp = TopAppBarDefaults.TopAppBarExpandedHeight,
windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(),
scrollBehavior: TopAppBarScrollBehavior? = null,
contentPadding: PaddingValues = TopAppBarDefaults.ContentPadding,
)
subtitle: @Composable () -> UnitRequiredSince 1.10
subtitle: @Composable () -> UnitRequiredSince 1.10A second, smaller line under the title.

TopAppBar(
title = { Text("Trip to Lisbon") },
subtitle = { Text("3 nights") },
navigationIcon = {
IconButton(onClick = {}) { Icon(Icons.Filled.Menu, "Menu") }
},
modifier = Modifier.width(360.dp),
)
titleHorizontalAlignment: Alignment.HorizontalOptionalSince 1.10
titleHorizontalAlignment: Alignment.HorizontalOptionalSince 1.10Default: Alignment.Start
Where the title sits: Alignment.Start or Alignment.CenterHorizontally.
Same as above: title, modifier, navigationIcon, actions, expandedHeight, windowInsets, colors, scrollBehavior, contentPadding.
Top app bar types
TopAppBarCenterAlignedTopAppBarMediumTopAppBarLargeTopAppBarMediumFlexibleTopAppBarLargeFlexibleTopAppBarTwoRowsTopAppBar
See also
TopAppBarDefaults: default values and helper functions forTopAppBar.