ConfirmDialog

fun ConfirmDialog(modifier: Modifier = Modifier, open: Boolean, title: String? = null, cancellable: Boolean = true, shape: Shape = MaterialTheme.shapes.medium, onConfirm: () -> Unit, onCancel: () -> Unit = {}, dismiss: () -> Unit, isLoading: Boolean = false, confirmButtonVisible: Boolean = true, confirmColor: Color = MaterialTheme.colorScheme.primary, confirmText: String? = null, cancelText: String? = null, content: @Composable () -> Unit)

A confirm dialog that can be used to confirm actions.

Parameters

modifier

Modifier to be applied to the dialog.

open

Whether the dialog should be displayed.

title

The title of the dialog.

cancellable

Whether the dialog can be dismissed by clicking outside of it.

onConfirm

The function to be called when the confirm button is clicked.

onCancel

The function to be called when the cancel button is clicked.

dismiss

The function to be called when the dialog is dismissed.

isLoading

Whether the confirm button should display a loading indicator.

confirmButtonVisible

Whether the confirm button should be visible.

confirmColor

The color of the confirm button.

confirmText

The text of the confirm button.

cancelText

The text of the cancel button.

content

The content of the dialog.

Example usage:

ConfirmDialog(
open = open,
title = "Are you sure?",
confirmText = "Yes I'm sure, cancel",
cancelText = "No, stay",
onConfirm = {
// Confirm action
},
dismiss = {
// Dismiss action
}
) {
// Your content
}

See also

for including your own content in a dialog without confirm buttons.