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.theme.LocalDismissState

Basic Usage

WindowBottomSheet component provides basic bottom sheet functionality:

kotlin
var showBottomSheet by remember { mutableStateOf(false) }

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

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

Properties

WindowBottomSheet Properties

Property NameTypeDescriptionDefault ValueRequired
showBooleanWhether to show the bottom sheet-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 colorBottomSheetDefaults.backgroundColor()No
enableWindowDimBooleanWhether to enable dimming layertrueNo
cornerRadiusDpCorner radius of the top cornersBottomSheetDefaults.cornerRadiusNo
sheetMaxWidthDpMaximum width of the bottom sheetBottomSheetDefaults.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 marginBottomSheetDefaults.outsideMarginNo
insideMarginDpSizeBottom sheet internal content marginBottomSheetDefaults.insideMarginNo
defaultWindowInsetsPaddingBooleanWhether to apply default window insets paddingtrueNo
dragHandleColorColorDrag indicator colorBottomSheetDefaults.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

BottomSheetDefaults Object

The BottomSheetDefaults object provides default settings for the bottom sheet component.

BottomSheetDefaults Properties

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

BottomSheetDefaults Functions

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

Advanced Usage

Action Buttons in Header

Use startAction and endAction to place buttons in the header area. LocalDismissState is provided in both action slots and the content slot:

kotlin
var showBottomSheet by remember { mutableStateOf(false) }

WindowBottomSheet(
    show = showBottomSheet,
    title = "Action Sheet",
    startAction = {
        val dismiss = LocalDismissState.current
        TextButton(
            text = "Cancel",
            onClick = { dismiss?.invoke() }
        )
    },
    endAction = {
        val dismiss = LocalDismissState.current
        TextButton(
            text = "Confirm",
            onClick = { dismiss?.invoke() }
        )
    },
    onDismissRequest = { showBottomSheet = false }
) {
    Text("Content with header action buttons")
}

Dismissing from Content

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

kotlin
WindowBottomSheet(
    show = showBottomSheet,
    title = "Dismiss Example",
    onDismissRequest = { showBottomSheet = false }
) {
    val dismiss = LocalDismissState.current

    TextButton(
        text = "Close Bottom Sheet",
        onClick = { dismiss?.invoke() }
    )
}

Changelog

Released under the Apache-2.0 License