Build apps faster with over 150+ styled components and screens! Check it out →

AlertDialogContent

Android

Component in Wear Material 3 Compose

This [AlertDialogContent] overload provides the content for an [AlertDialog] with 2 buttons to confirm or dismiss an action. Prefer using [AlertDialog] directly, which provides built-in animations and a streamlined API. This composable may be used to provide the content for an alert dialog if custom animations are required.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material3:1.0.0-alpha32")
}

Overloads

@Composable
fun AlertDialogContent(
    confirmButton: @Composable RowScope.() -> Unit,
    title: @Composable () -> Unit,
    dismissButton: @Composable RowScope.() -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (() -> Unit)? = null,
    text: @Composable (() -> Unit)? = null,
    verticalArrangement: Arrangement.Vertical = AlertDialogDefaults.VerticalArrangement,
    contentPadding: PaddingValues = AlertDialogDefaults.confirmDismissContentPadding(),
    content: (ScalingLazyListScope.() -> Unit)? = null
)

Parameters

namedescription
confirmButtonA slot for a [Button] indicating positive sentiment. Clicking the button must remove the dialog from the composition hierarchy. It's recommended to use [AlertDialogDefaults.ConfirmButton] in this slot with onClick callback.
titleA slot for displaying the title of the dialog. Title should contain a summary of the dialog's purpose or content and should not exceed 3 lines of text. By default, [TextOverflow.Ellipsis] will be applied when text exceeds 3 lines.
dismissButtonA slot for a [Button] indicating negative sentiment. Clicking the button must remove the dialog from the composition hierarchy. It's recommended to use [AlertDialogDefaults.DismissButton] in this slot with onClick callback.
modifierModifier to be applied to the dialog content.
iconOptional slot for an icon to be shown at the top of the dialog.
textOptional slot for displaying the message of the dialog below the title. Should contain additional text that presents further details about the dialog's purpose if the title is insufficient.
verticalArrangementThe vertical arrangement of the dialog's children. There is a default padding between icon, title, and text, which will be added to the spacing specified in this [verticalArrangement] parameter.
contentPaddingThe padding to apply around the entire dialog's contents.
contentA slot for additional content, displayed within a scrollable [ScalingLazyColumn].
@Composable
fun AlertDialogContent(
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (() -> Unit)? = null,
    text: @Composable (() -> Unit)? = null,
    verticalArrangement: Arrangement.Vertical = AlertDialogDefaults.VerticalArrangement,
    contentPadding: PaddingValues = AlertDialogDefaults.contentPadding(),
    content: (ScalingLazyListScope.() -> Unit)? = null
)

Parameters

namedescription
titleA slot for displaying the title of the dialog. Title should contain a summary of the dialog's purpose or content and should not exceed 3 lines of text. By default, [TextOverflow.Ellipsis] will be applied when text exceeds 3 lines.
modifierModifier to be applied to the dialog content.
iconOptional slot for an icon to be shown at the top of the dialog.
textOptional slot for displaying the message of the dialog below the title. Should contain additional text that presents further details about the dialog's purpose if the title is insufficient.
verticalArrangementThe vertical arrangement of the dialog's children. There is a default padding between icon, title, and text, which will be added to the spacing specified in this [verticalArrangement] parameter.
contentPaddingThe padding to apply around the entire dialog's contents.
contentA slot for additional content, displayed within a scrollable [ScalingLazyColumn].
@Composable
fun AlertDialogContent(
    edgeButton: (@Composable BoxScope.() -> Unit),
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    icon: @Composable (() -> Unit)? = null,
    text: @Composable (() -> Unit)? = null,
    verticalArrangement: Arrangement.Vertical = AlertDialogDefaults.VerticalArrangement,
    contentPadding: PaddingValues = AlertDialogDefaults.contentPadding(),
    content: (ScalingLazyListScope.() -> Unit)? = null
)

Parameters

namedescription
edgeButtonSlot for an [EdgeButton] indicating positive sentiment. Clicking the button must remove the dialog from the composition hierarchy. It's recommended to use [AlertDialogDefaults.EdgeButton] in this slot with onClick callback. Note that when using an [EdgeButton] which is not Medium size, the contentPadding parameters should be specified.
titleA slot for displaying the title of the dialog. Title should contain a summary of the dialog's purpose or content and should not exceed 3 lines of text. By default, [TextOverflow.Ellipsis] will be applied when text exceeds 3 lines.
modifierModifier to be applied to the dialog content.
iconOptional slot for an icon to be shown at the top of the dialog.
textOptional slot for displaying the message of the dialog below the title. Should contain additional text that presents further details about the dialog's purpose if the title is insufficient.
verticalArrangementThe vertical arrangement of the dialog's children. There is a default padding between icon, title, and text, which will be added to the spacing specified in this [verticalArrangement] parameter.
contentPaddingThe padding to apply around the entire dialog's contents. Bottom padding will be ignored and default spacing for the [EdgeButton] will be used.
contentA slot for additional content, displayed within a scrollable [ScalingLazyColumn].
by @alexstyl