androidx.compose.material3

BottomSheetScaffoldExperimental

Composable function

One of the bottom sheet types. It works like ModalBottomSheet. Only the parameters that differ are described here.

A screen layout with a sheet that is always there. Part of it shows at the bottom; the user drags it up.

A sheet that stays at the bottom of the screen
A sheet that stays at the bottom of the screen
Box(Modifier.size(360.dp, 400.dp)) {
    BottomSheetScaffold(
        sheetContent = {
            Column(Modifier.padding(horizontal = 16.dp).padding(bottom = 24.dp)) {
                Text("12 places nearby", style = MaterialTheme.typography.titleMedium)
                Text("Drag up to see the list")
            }
        },
        sheetPeekHeight = 120.dp,
    ) { padding ->
        Box(Modifier.fillMaxSize().padding(padding), contentAlignment = Alignment.Center) { Text("Map") }
    }
}

ParametersExperimental

@Composable
fun BottomSheetScaffold(
    sheetContent: @Composable ColumnScope.() -> Unit,
    modifier: Modifier = Modifier,
    scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
    sheetPeekHeight: Dp = BottomSheetDefaults.SheetPeekHeight,
    sheetMaxWidth: Dp = BottomSheetDefaults.SheetMaxWidth,
    sheetShape: Shape = BottomSheetDefaults.ExpandedShape,
    sheetContainerColor: Color = BottomSheetDefaults.ContainerColor,
    sheetContentColor: Color = contentColorFor(sheetContainerColor),
    sheetTonalElevation: Dp = 0.dp,
    sheetShadowElevation: Dp = BottomSheetDefaults.Elevation,
    sheetDragHandle: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
    sheetSwipeEnabled: Boolean = true,
    topBar: @Composable (() -> Unit)? = null,
    snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
    containerColor: Color = MaterialTheme.colorScheme.surface,
    contentColor: Color = contentColorFor(containerColor),
    content: @Composable (PaddingValues) -> Unit,
)

sheetContent: @Composable ColumnScope.() -> UnitRequired

What the sheet of a BottomSheetScaffold shows.

scaffoldState: BottomSheetScaffoldStateOptional

Default: rememberBottomSheetScaffoldState()

Holds the sheet state and the snackbar state of a BottomSheetScaffold. Create it with rememberBottomSheetScaffoldState().

sheetPeekHeight: DpOptional

Default: BottomSheetDefaults.SheetPeekHeight

How much of the sheet shows when it is down.

sheetShape: ShapeOptional

Default: BottomSheetDefaults.ExpandedShape

Sets the outline of the sheet.

sheetContainerColor: ColorOptional

Default: BottomSheetDefaults.ContainerColor

The background color of the sheet.

sheetContentColor: ColorOptional

Default: contentColorFor(sheetContainerColor)

The default color for text and icons in the sheet.

sheetTonalElevation: DpOptional

Default: 0.dp

Tints the sheet a little toward the primary color.

sheetShadowElevation: DpOptional

Default: BottomSheetDefaults.Elevation

The size of the shadow above the sheet.

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

Default: { BottomSheetDefaults.DragHandle() }

The small bar at the top of the sheet. Pass null to hide it.

sheetSwipeEnabled: BooleanOptional

Default: true

Set to false to stop the user from dragging the sheet.

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

Default: null

A bar at the top of a BottomSheetScaffold, like in a Scaffold.

snackbarHost: @Composable (SnackbarHostState) -> UnitOptional

Default: { SnackbarHost(it) }

Where snackbars appear in a BottomSheetScaffold.

content: @Composable (PaddingValues) -> UnitRequired

What the sheet shows. Items are placed in a Column.

Defaults that differ from ModalBottomSheet:

Same as in ModalBottomSheet: modifier, sheetMaxWidth, containerColor, contentColor.

Bottom sheet types

See also