Confirm Dialog
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.
on Confirm
The function to be called when the confirm button is clicked.
on Cancel
The function to be called when the cancel button is clicked.
dismiss
The function to be called when the dialog is dismissed.
is Loading
Whether the confirm button should display a loading indicator.
confirm Button Visible
Whether the confirm button should be visible.
confirm Color
The color of the confirm button.
confirm Text
The text of the confirm button.
cancel Text
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
}
Content copied to clipboard
See also
for including your own content in a dialog without confirm buttons.