Skip to content

WindowDialog

WindowDialog is a window-level dialog 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.WindowDialog
import top.yukonga.miuix.kmp.theme.LocalDismissState

Basic Usage

kotlin
var showDialog by remember { mutableStateOf(false) }

TextButton(
    text = "Open",
    onClick = { showDialog = true }
)

WindowDialog(
    title = "WindowDialog",
    summary = "A basic window-level dialog",
    show = showDialog,
    onDismissRequest = { showDialog = false }
) {
    val dismiss = LocalDismissState.current
    TextButton(
        text = "Confirm",
        onClick = { dismiss?.invoke() },
        modifier = Modifier.fillMaxWidth()
    )
}

Properties

WindowDialog Properties

Property NameTypeDescriptionDefault ValueRequired
showBooleanWhether to show the dialog-Yes
modifierModifierRoot content modifierModifierNo
titleString?Dialog titlenullNo
titleColorColorTitle colorDialogDefaults.titleColor()No
summaryString?Dialog summarynullNo
summaryColorColorSummary colorDialogDefaults.summaryColor()No
backgroundColorColorDialog background colorDialogDefaults.backgroundColor()No
enableWindowDimBooleanWhether to enable dimming layertrueNo
onDismissRequest(() -> Unit)?Called when the user requests dismissal (outside tap or back)nullNo
onDismissFinished(() -> Unit)?Callback after dialog fully dismissesnullNo
outsideMarginDpSizeOuter margin (window edges)DialogDefaults.outsideMarginNo
insideMarginDpSizeInner padding for dialog contentDialogDefaults.insideMarginNo
defaultWindowInsetsPaddingBooleanApply default insets padding (IME, nav, caption)trueNo
content@Composable () -> UnitDialog content-Yes

DialogDefaults

Properties

NameTypeDescription
outsideMarginDpSizeDefault outer margin for dialog
insideMarginDpSizeDefault inner padding for dialog

Functions

NameReturn TypeDescription
titleColor()ColorGet default title color
summaryColor()ColorGet default summary color
backgroundColor()ColorGet default dialog background color

LocalDismissState

Provides a (() -> Unit)? function to close the current popup from within the content. This is a unified dismiss state provided by all overlay components.

kotlin
val dismiss = LocalDismissState.current
TextButton(
    text = "Close",
    onClick = { dismiss?.invoke() }
)

Changelog

Released under the Apache-2.0 License