Compose Component

AlertDialog

Displays an urgent prompt requiring the user to acknowledge or take an action.

AlertDialog

Source set: Android
@Composable
public fun AlertDialog(
    onDismissRequest: () -> Unit,
    confirmButton: @Composable () -> Unit,
    text: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    dismissButton: @Composable (() -> Unit)? = null,
    icon: @Composable (() -> Unit)? = null,
    title: @Composable (() -> Unit)? = null,
    shape: Shape = AlertDialogDefaults.shape,
    containerColor: Color = AlertDialogDefaults.containerColor,
    contentColor: Color = AlertDialogDefaults.contentColor(containerColor),
    contentPadding: PaddingValues = AlertDialogDefaults.contentPadding,
)

Parameters

onDismissRequest called when the user tries to dismiss the dialog
confirmButton button used to confirm or accept the action. This will be the first button shown and takes focus upon the dialog being opened
text body text providing additional details or explanation for the dialog, placed below the title
modifier the Modifier to be applied to the dialog
dismissButton optional button used to dismiss or cancel the alert dialog
icon optional icon displayed at the top of the dialog, above the title
title optional title displaying the primary headline of the dialog, placed below the icon and above the text
shape the Shape of the dialog container
containerColor the background Color of the dialog container
contentColor the default Color for content inside the dialog container
contentPadding the spacing values to apply internally between the container and the content

Content updated: