Alert Dialog

Alert Dialog

Displays modal dialogs for important information, decisions, or user input.


Installation

./gradlew lumo --add AlertDialog

Usage

Basic Example

if (visible) {
    AlertDialog(
        onDismissRequest = { /* Handle dismiss */ },
        onConfirmClick = { /* Handle confirm */ },
        title = "Simple Alert",
        text = "This is a basic alert dialog with default buttons",
        confirmButtonText = "OK",
        dismissButtonText = "Cancel"
    )
}

Custom Dialog

BasicAlertDialog(onDismissRequest = { state.showCustomContentDialog = false }) {
    Column(
        modifier = Modifier
            .background(AppTheme.colors.primary)
            .padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(16.dp)
    ) {
        CompositionLocalProvider(
            LocalContentColor provides AppTheme.colors.onPrimary
        ) {
            Text("Custom Content", style = AppTheme.typography.h4)
 
            Text("This dialog allows for fully customizable content.")
 
            Button(
                text = "Close",
                variant = ButtonVariant.Secondary,
                onClick = { state.showCustomContentDialog = false },
                modifier = Modifier.fillMaxWidth()
            )
        }
    }
}

API Documentation

AlertDialog

The AlertDialog composable creates a modal dialog with customizable content, buttons, and styling.

Parameters

ParameterTypeDefaultDescription
onDismissRequest() -> Unit-Called when dialog should be dismissed
onConfirmClick() -> Unit-Called when confirm button is clicked
titleString-Dialog title text
textString-Dialog content text
confirmButtonTextString”OK”Text for confirm button
dismissButtonTextString?”Cancel”Text for dismiss button (null to hide)
icon@Composable (() -> Unit)?nullOptional icon to display above title
shapeShapeRoundedCornerShapeDialog corner shape
containerColorColorWhiteBackground color of dialog
iconContentColorColorPrimaryColor of the icon
titleContentColorColorPrimaryColor of the title text
textContentColorColorPrimaryColor of the content text
elevationDp4.dpDialog elevation shadow
propertiesDialogPropertiesDefaultWindow properties for the dialog
content@Composable (() -> Unit)?nullOptional custom content instead of default layout

BasicAlertDialog

This is the foundational component for fully custom content.

Parameters

ParameterTypeDescription
onDismissRequest() -> UnitCalled when dialog should be dismissed
modifierModifierModifier for the dialog container
propertiesDialogPropertiesWindow properties for the dialog
content@Composable () -> UnitCustom content to display in dialog