androidx.compose.material3

HorizontalFloatingToolbarSince 1.10

Composable function

A floating toolbar holds actions for the current screen. It floats above the content, so it can show and hide while the user scrolls.

A standard floating toolbarExpressive theme
A standard floating toolbar
HorizontalFloatingToolbar(expanded = true) {
    IconButton(onClick = {}) { Icon(Icons.Filled.Edit, "Edit") }
    IconButton(onClick = {}) { Icon(Icons.Filled.Share, "Share") }
    IconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Favorite") }
    IconButton(onClick = {}) { Icon(Icons.Filled.Settings, "Settings") }
}

With a FAB, the toolbar collapses into the FAB while the user scrolls, and opens again when they scroll back.

A floating toolbar with a FABExpressive theme
A floating toolbar with a FAB
HorizontalFloatingToolbar(
    expanded = true,
    floatingActionButton = {
        FloatingToolbarDefaults.VibrantFloatingActionButton(onClick = {}) { Icon(Icons.Filled.Add, "Add") }
    },
    colors = FloatingToolbarDefaults.vibrantFloatingToolbarColors(),
) {
    IconButton(onClick = {}) { Icon(Icons.Filled.Edit, "Edit") }
    IconButton(onClick = {}) { Icon(Icons.Filled.Share, "Share") }
    IconButton(onClick = {}) { Icon(Icons.Filled.Favorite, "Favorite") }
}

Place it with Modifier.align(...) in a Box, or in the floatingActionButton slot of a Scaffold.

Basic

Actions only.

@Composable
fun HorizontalFloatingToolbar(
    expanded: Boolean,
    modifier: Modifier = Modifier,
    colors: FloatingToolbarColors = FloatingToolbarDefaults.standardFloatingToolbarColors(),
    contentPadding: PaddingValues = FloatingToolbarDefaults.ContentPadding,
    scrollBehavior: FloatingToolbarScrollBehavior? = null,
    shape: Shape = FloatingToolbarDefaults.ContainerShape,
    leadingContent: @Composable (RowScope.() -> Unit)? = null,
    trailingContent: @Composable (RowScope.() -> Unit)? = null,
    expandedShadowElevation: Dp = FloatingToolbarDefaults.ContainerExpandedElevation,
    collapsedShadowElevation: Dp = FloatingToolbarDefaults.ContainerCollapsedElevation,
    content: @Composable RowScope.() -> Unit,
)

expanded: BooleanRequired

Whether the toolbar is open. With a FAB, a closed toolbar shows only the FAB.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. See the Modifier guide.

colors: FloatingToolbarColorsOptional

contentPadding: PaddingValuesOptional

Default: FloatingToolbarDefaults.ContentPadding

Space between the edge of the toolbar and its content.

scrollBehavior: FloatingToolbarScrollBehavior?Optional

Default: null

Hides or collapses the toolbar while the user scrolls. Get one from FloatingToolbarDefaults.exitAlwaysScrollBehavior(...).

shape: ShapeOptional

Default: FloatingToolbarDefaults.ContainerShape

Sets the outline. Default: fully round.

leadingContent: @Composable (RowScope.() -> Unit)?Optional

Default: null

Items at the start, shown only while the toolbar is open.

trailingContent: @Composable (RowScope.() -> Unit)?Optional

Default: null

Items at the end, shown only while the toolbar is open.

expandedShadowElevation: DpOptional

Default: FloatingToolbarDefaults.ContainerExpandedElevation

The shadow while the toolbar is open.

collapsedShadowElevation: DpOptional

Default: FloatingToolbarDefaults.ContainerCollapsedElevation

The shadow while the toolbar is closed.

content: @Composable RowScope.() -> UnitRequired

The actions. Usually IconButtons.

With FAB

Actions plus a floating action button next to them.

@Composable
fun HorizontalFloatingToolbar(
    expanded: Boolean,
    floatingActionButton: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    colors: FloatingToolbarColors = FloatingToolbarDefaults.standardFloatingToolbarColors(),
    contentPadding: PaddingValues = FloatingToolbarDefaults.ContentPadding,
    scrollBehavior: FloatingToolbarScrollBehavior? = null,
    shape: Shape = FloatingToolbarDefaults.ContainerShape,
    floatingActionButtonPosition: FloatingToolbarHorizontalFabPosition = FloatingToolbarHorizontalFabPosition.End,
    animationSpec: FiniteAnimationSpec<Float> = FloatingToolbarDefaults.animationSpec(),
    expandedShadowElevation: Dp = FloatingToolbarDefaults.ContainerExpandedElevationWithFab,
    collapsedShadowElevation: Dp = FloatingToolbarDefaults.ContainerCollapsedElevationWithFab,
    content: @Composable RowScope.() -> Unit,
)

floatingActionButton: @Composable () -> UnitRequired

The FAB next to the toolbar. Use FloatingToolbarDefaults.StandardFloatingActionButton or VibrantFloatingActionButton.

floatingActionButtonPosition: FloatingToolbarHorizontalFabPositionOptional

Default: FloatingToolbarHorizontalFabPosition.End

Which side the FAB sits on.

animationSpec: FiniteAnimationSpec<Float>Optional

Default: FloatingToolbarDefaults.animationSpec()

How the toolbar animates when it opens and closes.

Same as above: expanded, modifier, colors, contentPadding, scrollBehavior, shape, expandedShadowElevation, collapsedShadowElevation, content.

Floating toolbar types