Dialog

A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.

Dialog renders a modal overlay with three optional slots — header, body, and footer. The header slot automatically includes a close (×) button in the top-right corner. All slots are optional so you can compose only what you need.

Basic Usage

A confirmation dialog uses only header and footer. DialogTitle and DialogDescription provide the correct typography inside the header slot; DialogAction and DialogCancel render the primary and outline buttons in the footer.

With Body Content

Use the body slot to place form fields, lists, or any freeform content between the header and footer.

Header Only

When no user action is needed you can omit footer entirely. The close button in the header corner still dismisses the dialog.

import com.komoui.components.Dialog
import com.komoui.components.DialogDescription
import com.komoui.components.DialogTitle
 
@Composable
fun Example() {
    var showDialog by remember { mutableStateOf(false) }
 
    Dialog(
        open = showDialog,
        onDismissRequest = { showDialog = false },
        header = {
            DialogTitle { Text("Information") }
            DialogDescription { Text("This action has been completed successfully.") }
        }
    )
}

API Reference

Dialog

ParameterTypeDefaultDescription
openBooleanControls whether the dialog is visible.
onDismissRequest() -> UnitCalled when the user taps outside the dialog or the close button.
modifierModifierModifierApplied to the dialog's content container.
header(@Composable ColumnScope.() -> Unit)?nullHeader slot. Rendered alongside an auto-inserted close button. Typically contains DialogTitle and DialogDescription.
body(@Composable ColumnScope.() -> Unit)?nullBody slot. Placed between header and footer. Use for forms, lists, or freeform content.
footer(@Composable RowScope.() -> Unit)?nullFooter slot. Rendered in a right-aligned Row. Typically contains DialogCancel and DialogAction.

DialogTitle

Applies foreground color, 18 sp, and SemiBold weight to its content via ProvideTextStyle.

ParameterTypeDefaultDescription
modifierModifierModifierApplied to the title container.
content@Composable () -> UnitSlot content — typically a Text.

DialogDescription

Applies mutedForeground color and 14 sp to its content via ProvideTextStyle.

ParameterTypeDefaultDescription
modifierModifierModifierApplied to the description container.
content@Composable () -> UnitSlot content — typically a Text.

DialogAction

A primary action button using ButtonVariant.Default. Place inside the footer slot.

ParameterTypeDefaultDescription
onClick() -> UnitCalled when the button is tapped.
modifierModifierModifierApplied to the button.
content@Composable () -> UnitButton label — typically a Text.

DialogCancel

A secondary cancel button using ButtonVariant.Outline. Place inside the footer slot.

ParameterTypeDefaultDescription
onClick() -> UnitCalled when the button is tapped.
modifierModifierModifierApplied to the button.
content@Composable () -> UnitButton label — typically a Text.
Edit this page on GitHub