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.window.WindowDialog
import top.yukonga.miuix.kmp.theme.LocalDismissStateBasic 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 Name | Type | Description | Default Value | Required |
|---|---|---|---|---|
| show | Boolean | Whether to show the dialog | - | Yes |
| modifier | Modifier | Root content modifier | Modifier | No |
| title | String? | Dialog title | null | No |
| titleColor | Color | Title color | DialogDefaults.titleColor() | No |
| summary | String? | Dialog summary | null | No |
| summaryColor | Color | Summary color | DialogDefaults.summaryColor() | No |
| backgroundColor | Color | Dialog background color | DialogDefaults.backgroundColor() | No |
| enableWindowDim | Boolean | Whether to enable dimming layer | true | No |
| onDismissRequest | (() -> Unit)? | Called when the user requests dismissal (outside tap or back) | null | No |
| onDismissFinished | (() -> Unit)? | Invoked after the hide animation completes; not invoked if the hide is cancelled mid-flight (e.g., show toggled back to true) | null | No |
| outsideMargin | DpSize | Outer margin (window edges) | DialogDefaults.outsideMargin | No |
| insideMargin | DpSize | Inner padding for dialog content | DialogDefaults.insideMargin | No |
| defaultWindowInsetsPadding | Boolean | Apply default insets padding (IME, nav, caption) | true | No |
| maxWidth | Dp | Maximum width of the dialog | DialogDefaults.MaxWidth | No |
| largeScreen | Boolean? | Overrides the large-screen presentation (centered scale/fade instead of bottom slide-in). When null, detected from the window size | null | No |
| cornerRadius | Dp? | Overrides the dialog corner radius. When null, DialogDefaults.CornerRadius for the centered presentation, or derived from the screen corner radius (clamped to 32dp..48dp) when bottom-attached | null | No |
| content | @Composable () -> Unit | Dialog content | - | Yes |
DialogDefaults
Properties
| Name | Type | Description |
|---|---|---|
| MaxWidth | Dp | Default maximum dialog width |
| CornerRadius | Dp | Default corner radius of the centered (large-screen) presentation |
| outsideMargin | DpSize | Default outer margin for dialog |
| insideMargin | DpSize | Default inner padding for dialog |
Functions
| Name | Return Type | Description |
|---|---|---|
| titleColor() | Color | Get default title color |
| summaryColor() | Color | Get default summary color |
| backgroundColor() | Color | Get 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() }
)

