State of Compose 2023 results are in! Click here to learn more

← Back to Material Compose

BottomSheetScaffold

Component
in
Material
. Since 1.0.0

Overview

Code Examples

<a href="https://material.io/components/sheets-bottom#standard-bottom-sheet" class="external" target="_blank">Material Design standard bottom sheet</a>.

Standard bottom sheets co-exist with the screen’s main UI region and allow for simultaneously viewing and interacting with both regions. They are commonly used to keep a feature or secondary content visible on screen when content in main UI region is frequently scrolled or panned.

!Standard bottom sheet image(https://developer.android.com/images/reference/androidx/compose/material/standard-bottom-sheet.png)

This component provides an API to put together several material components to construct your screen. For a similar component which implements the basic material design layout strategy with app bars, floating action buttons and navigation drawers, use the standard Scaffold. For similar component that uses a backdrop as the centerpiece of the screen, use BackdropScaffold.

A simple example of a bottom sheet scaffold looks like this:

Overloads

BottomSheetScaffold

@Composable
@ExperimentalMaterialApi
fun BottomSheetScaffold(
    sheetContent: @Composable ColumnScope.() -> Unit,
    modifier: Modifier = Modifier,
    scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
    topBar: (@Composable () -> Unit)? = null,
    snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
    floatingActionButton: (@Composable () -> Unit)? = null,
    floatingActionButtonPosition: FabPosition = FabPosition.End,
    sheetGesturesEnabled: Boolean = true,
    sheetShape: Shape = MaterialTheme.shapes.large,
    sheetElevation: Dp = BottomSheetScaffoldDefaults.SheetElevation,
    sheetBackgroundColor: Color = MaterialTheme.colors.surface,
    sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
    sheetPeekHeight: Dp = BottomSheetScaffoldDefaults.SheetPeekHeight,
    backgroundColor: Color = MaterialTheme.colors.background,
    contentColor: Color = contentColorFor(backgroundColor),
    content: @Composable (PaddingValues) -> Unit
)

Parameters

NameDescription
sheetContentThe content of the bottom sheet.
modifierAn optional Modifier for the root of the scaffold.
scaffoldStateThe state of the scaffold.
topBarAn optional top app bar.
snackbarHostThe composable hosting the snackbars shown inside the scaffold.
floatingActionButtonAn optional floating action button.
floatingActionButtonPositionThe position of the floating action button.
sheetGesturesEnabledWhether the bottom sheet can be interacted with by gestures.
sheetShapeThe shape of the bottom sheet.
sheetElevationThe elevation of the bottom sheet.
sheetBackgroundColorThe background color of the bottom sheet.
sheetContentColorThe preferred content color provided by the bottom sheet to its children. Defaults to the matching content color for sheetBackgroundColor, or if that is not a color from the theme, this will keep the same content color set above the bottom sheet.
sheetPeekHeightThe height of the bottom sheet when it is collapsed. If the peek height equals the sheet's full height, the sheet will only have a collapsed state.
backgroundColorThe background color of the scaffold body.
contentColorThe color of the content in scaffold body. Defaults to either the matching content color for backgroundColor, or, if it is not a color from the theme, this will keep the same value set above this Surface.
contentThe main content of the screen. You should use the provided PaddingValues to properly offset the content, so that it is not obstructed by the bottom sheet when collapsed

BottomSheetScaffold

@Suppress("UNUSED_PARAMETER")
@Deprecated(message = BottomSheetScaffoldWithDrawerDeprecated, level = DeprecationLevel.ERROR)
@Composable
@ExperimentalMaterialApi
fun BottomSheetScaffold(
    sheetContent: @Composable ColumnScope.() -> Unit,
    modifier: Modifier = Modifier,
    scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
    topBar: (@Composable () -> Unit)? = null,
    snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
    floatingActionButton: (@Composable () -> Unit)? = null,
    floatingActionButtonPosition: FabPosition = FabPosition.End,
    sheetGesturesEnabled: Boolean = true,
    sheetShape: Shape = MaterialTheme.shapes.large,
    sheetElevation: Dp = BottomSheetScaffoldDefaults.SheetElevation,
    sheetBackgroundColor: Color = MaterialTheme.colors.surface,
    sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
    sheetPeekHeight: Dp = BottomSheetScaffoldDefaults.SheetPeekHeight,
    drawerContent: @Composable (ColumnScope.() -> Unit)? = null,
    drawerGesturesEnabled: Boolean = true,
    drawerShape: Shape = MaterialTheme.shapes.large,
    drawerElevation: Dp = DrawerDefaults.Elevation,
    drawerBackgroundColor: Color = MaterialTheme.colors.surface,
    drawerContentColor: Color = contentColorFor(drawerBackgroundColor),
    drawerScrimColor: Color = DrawerDefaults.scrimColor,
    backgroundColor: Color = MaterialTheme.colors.background,
    contentColor: Color = contentColorFor(backgroundColor),
    content: @Composable (PaddingValues) -> Unit
)

Parameters

NameDescription
sheetContentThe content of the bottom sheet.
modifierAn optional Modifier for the root of the scaffold.
scaffoldStateThe state of the scaffold.
topBarAn optional top app bar.
snackbarHostThe composable hosting the snackbars shown inside the scaffold.
floatingActionButtonAn optional floating action button.
floatingActionButtonPositionThe position of the floating action button.
sheetGesturesEnabledWhether the bottom sheet can be interacted with by gestures.
sheetShapeThe shape of the bottom sheet.
sheetElevationThe elevation of the bottom sheet.
sheetBackgroundColorThe background color of the bottom sheet.
sheetContentColorThe preferred content color provided by the bottom sheet to its children. Defaults to the matching content color for sheetBackgroundColor, or if that is not a color from the theme, this will keep the same content color set above the bottom sheet.
sheetPeekHeightThe height of the bottom sheet when it is collapsed. If the peek height equals the sheet's full height, the sheet will only have a collapsed state.
drawerContentThe content of the drawer sheet.
drawerGesturesEnabledWhether the drawer sheet can be interacted with by gestures.
drawerShapeThe shape of the drawer sheet.
drawerElevationThe elevation of the drawer sheet.
drawerBackgroundColorThe background color of the drawer sheet.
drawerContentColorThe preferred content color provided by the drawer sheet to its children. Defaults to the matching content color for drawerBackgroundColor, or if that is not a color from the theme, this will keep the same content color set above the drawer sheet.
drawerScrimColorThe color of the scrim that is applied when the drawer is open.
backgroundColorThe background color of the scaffold body.
contentColorThe color of the content in scaffold body. Defaults to either the matching content color for backgroundColor, or, if it is not a color from the theme, this will keep the same value set above this Surface.
contentThe main content of the screen. You should use the provided PaddingValues to properly offset the content, so that it is not obstructed by the bottom sheet when collapsed