State of Compose 2023 results are in! Click here to learn more

← Back to Wear Material

ConfirmationDialog

Component
in
Wear Material
. Since 1.0.0-alpha12

Overview

Code Examples

Video

ConfirmationDialog is an opinionated dialog that displays a message to the user for durationMillis. It has a slot for an icon or image (which could be animated).

ConfirmationDialog can also be acknowledged via swipe-to-dismiss if the dialog is displayed as a destination in a navigation graph e.g. using SwipeDismissableNavHost.

Example of a ConfirmationDialog with animation:

Overloads

ConfirmationDialog

@Composable
public fun ConfirmationDialog(
    onTimeout: () -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (() -> Unit)? = null,
    scrollState: ScrollState = rememberScrollState(),
    durationMillis: Long = DialogDefaults.ShortDurationMillis,
    backgroundColor: Color = MaterialTheme.colors.background,
    contentColor: Color = contentColorFor(backgroundColor),
    iconTintColor: Color = contentColor,
    contentPadding: PaddingValues = DialogDefaults.ConfirmationContentPadding,
    content: @Composable () -> Unit
)

Parameters

NameDescription
onTimeoutEvent invoked when the dialog has been shown for durationMillis. Must remove the ConfirmationDialog from the composition.
modifierModifier to be applied to the dialog.
iconAn optional slot for displaying an icon or image.
scrollStateThe scroll state for the dialog so that the scroll position can be displayed e.g. by the PositionIndicator passed to Scaffold.
durationMillisThe number of milliseconds for which the dialog is displayed, must be positive. Suggested values are DialogDefaults.ShortDurationMillis, DialogDefaults.LongDurationMillis or DialogDefaults.IndefiniteDurationMillis.
backgroundColorColor representing the background color for this dialog.
contentColorColor representing the color for content.
iconTintColorIcon Color that defaults to the contentColor, unless specifically overridden.
contentPaddingThe padding to apply around the whole of the dialog's contents.
contentA slot for the dialog title, expected to be one line of text