Skip to content

WindowBottomSheet

WindowBottomSheet is a window-level bottom sheet component. It renders using platform Dialog and does not require Scaffold or MiuixPopupHost. It supports large-screen optimized animations, system back gesture dismissal, and a composition local to request dismiss from inside content.

TIP

This component is independent of Scaffold and can be used in any composable scope.

Import

kotlin
import top.yukonga.miuix.kmp.extra.WindowBottomSheet
import top.yukonga.miuix.kmp.extra.LocalWindowBottomSheetState

Basic Usage

WindowBottomSheet component provides basic bottom sheet functionality:

kotlin
var showBottomSheet = remember { mutableStateOf(false) }

// Can be used anywhere
TextButton(
    text = "Show Window Bottom Sheet",
    onClick = { showBottomSheet.value = true }
)

WindowBottomSheet(
    show = showBottomSheet,
    title = "Window Bottom Sheet Title",
    onDismissRequest = { showBottomSheet.value = false }
) {
    val dismiss = LocalWindowBottomSheetState.current
    Text(text = "This is the content of the window bottom sheet")
    TextButton(
        text = "Close",
        onClick = { dismiss?.invoke() }
    )
}

Properties

WindowBottomSheet Properties

Property NameTypeDescriptionDefault ValueRequired
showMutableState<Boolean>State object to control bottom sheet visibility-Yes
modifierModifierModifier applied to the bottom sheetModifierNo
titleString?Bottom sheet titlenullNo
startAction@Composable (() -> Unit)?Optional composable for start action (e.g., close button)nullNo
endAction@Composable (() -> Unit)?Optional composable for end action (e.g., submit button)nullNo
backgroundColorColorBottom sheet background colorWindowBottomSheetDefaults.backgroundColor()No
enableWindowDimBooleanWhether to enable dimming layertrueNo
cornerRadiusDpCorner radius of the top cornersWindowBottomSheetDefaults.cornerRadiusNo
sheetMaxWidthDpMaximum width of the bottom sheetWindowBottomSheetDefaults.maxWidthNo
onDismissRequest(() -> Unit)?Called when the user requests dismissal (outside tap or back)nullNo
onDismissFinished(() -> Unit)?Callback after bottom sheet fully dismissesnullNo
outsideMarginDpSizeBottom sheet external marginWindowBottomSheetDefaults.outsideMarginNo
insideMarginDpSizeBottom sheet internal content marginWindowBottomSheetDefaults.insideMarginNo
defaultWindowInsetsPaddingBooleanWhether to apply default window insets paddingtrueNo
dragHandleColorColorDrag indicator colorWindowBottomSheetDefaults.dragHandleColor()No
allowDismissBooleanWhether to allow dismissing the sheet via drag or back gesturetrueNo
enableNestedScrollBooleanWhether to enable nested scrolling for the contenttrueNo
content@Composable () -> UnitBottom sheet content-Yes

WindowBottomSheetDefaults Object

The WindowBottomSheetDefaults object provides default settings for the SuperBottomSheet component.

WindowBottomSheetDefaults Properties

Property NameTypeDescription
cornerRadiusDpDefault corner radius (28.dp)
maxWidthDpDefault maximum width (640.dp)
outsideMarginDpSizeDefault bottom sheet external margin
insideMarginDpSizeDefault bottom sheet internal margin

WindowBottomSheetDefaults Functions

Function NameReturn TypeDescription
backgroundColor()ColorGet default background color
dragHandleColor()ColorGet default drag indicator color

Advanced Usage

Dismissing from Content

You can use LocalWindowBottomSheetState to dismiss the bottom sheet from within its content:

kotlin
WindowBottomSheet(
    show = showBottomSheet,
    title = "Dismiss Example",
    onDismissRequest = { showBottomSheet.value = false }
) {
    val dismiss = LocalWindowBottomSheetState.current
    
    Button(
        onClick = { dismiss?.invoke() }
    ) {
        Text("Close Bottom Sheet")
    }
}

Changelog

Released under the Apache-2.0 License