androidx.compose.material3

ModalBottomSheetExperimental

Composable function

A bottom sheet slides up from the bottom and shows extra content or actions.

A modal bottom sheet
A modal bottom sheet
// The Box only gives the picture a size. In an app, show the sheet when a state is true.
Box(Modifier.size(360.dp, 420.dp)) {
    ModalBottomSheet(onDismissRequest = {}) {
        Column(Modifier.padding(horizontal = 16.dp).padding(bottom = 24.dp)) {
            Text("Share with")
            Spacer(Modifier.height(8.dp))
            listOf("Email" to Icons.Filled.Email, "Messages" to Icons.Filled.Share).forEach { (label, icon) ->
                NavigationDrawerItem(
                    label = { Text(label) },
                    icon = { Icon(icon, null) },
                    selected = false,
                    onClick = {},
                )
            }
        }
    }
}

BottomSheet is the sheet on its own, without a scaffold or dim layer, for your own layouts.

A modal sheet is shown while it is in the composition. Keep a Boolean state and wrap it in if (showSheet) { ... }. To close it with an animation, call sheetState.hide() from a coroutine, then set your state to false.

ParametersExperimental

@Composable
fun ModalBottomSheet(
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    sheetState: SheetState = rememberBottomSheetState(initialValue = Hidden),
    sheetMaxWidth: Dp = BottomSheetDefaults.SheetMaxWidth,
    sheetGesturesEnabled: Boolean = true,
    shape: Shape = BottomSheetDefaults.ExpandedShape,
    containerColor: Color = BottomSheetDefaults.ContainerColor,
    contentColor: Color = contentColorFor(containerColor),
    tonalElevation: Dp = 0.dp,
    scrimColor: Color = BottomSheetDefaults.ScrimColor,
    dragHandle: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
    contentWindowInsets: @Composable () -> WindowInsets = { BottomSheetDefaults.modalWindowInsets },
    properties: ModalBottomSheetProperties = ModalBottomSheetProperties(),
    content: @Composable ColumnScope.() -> Unit,
)

onDismissRequest: () -> UnitRequired

Called when the user swipes the sheet down, taps outside, or presses back. Set your state to false here.

modifier: ModifierOptional

Default: Modifier

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

sheetState: SheetStateOptional

Default: rememberBottomSheetState(initialValue = Hidden)

Controls and reads the position of the sheet: hidden, partly open or fully open. Create it with rememberBottomSheetState(...).

sheetMaxWidth: DpOptional

Default: BottomSheetDefaults.SheetMaxWidth

The widest the sheet can be. On wide screens it is centered.

sheetGesturesEnabled: BooleanOptionalSince 1.9

Default: true

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

shape: ShapeOptional

Default: BottomSheetDefaults.ExpandedShape

Sets the outline. Default: rounded top corners.

containerColor: ColorOptional

Default: BottomSheetDefaults.ContainerColor

The background color.

contentColor: ColorOptional

Default: contentColorFor(containerColor)

The default color for text and icons inside.

tonalElevation: DpOptional

Default: 0.dp

Tints the background a little toward the primary color.

scrimColor: ColorOptional

Default: BottomSheetDefaults.ScrimColor

The color of the dim layer behind a modal sheet.

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

Default: { BottomSheetDefaults.DragHandle() }

The small bar at the top that shows the sheet can be dragged. Pass null to hide it.

contentWindowInsets: @Composable () -> WindowInsetsOptional

Default: { BottomSheetDefaults.modalWindowInsets }

Space kept free for system bars inside the sheet.

properties: ModalBottomSheetPropertiesOptional

Default: ModalBottomSheetProperties()

Window options for the modal sheet, like whether back closes it.

content: @Composable ColumnScope.() -> UnitRequired

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

Bottom sheet types

See also