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

← Back to Wear Material

Dialog

Component
in
Wear Material
. Since 1.0.0

Overview

Code Examples

Video

Dialog displays a full-screen dialog, layered over any other content. It takes a single slot, which is expected to be an opinionated Wear dialog content, such as Alert or Confirmation.

The dialog supports swipe-to-dismiss and reveals the parent content in the background during the swipe gesture.

Example of content using Dialog to trigger an alert dialog using Alert:

Overloads

Dialog

@Composable
public fun Dialog(
    showDialog: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    scrollState: ScalingLazyListState? = rememberScalingLazyListState(),
    properties: DialogProperties = DialogProperties(),
    content: @Composable () -> Unit,
)

Parameters

NameDescription
showDialogControls whether to display the Dialog. Set to true initially to trigger an 'intro' animation and display the Dialog. Subsequently, setting to false triggers an 'outro' animation, then Dialog calls onDismissRequest and hides itself.
onDismissRequestExecutes when the user dismisses the dialog. Must remove the dialog from the composition.
modifierModifier to be applied to the dialog.
scrollStateThe scroll state for the dialog so that the scroll position can be displayed.
propertiesTypically platform specific properties to further configure the dialog.
contentSlot for dialog content such as Alert or Confirmation

Dialog

@Suppress("DEPRECATION")
@Deprecated(
    "This overload is provided for backwards compatibility with Compose for Wear OS 1.1." +
        "A newer overload is available which uses ScalingLazyListState from " +
        "wear.compose.foundation.lazy package", level = DeprecationLevel.HIDDEN
)
@Composable
public fun Dialog(
    showDialog: Boolean,
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    scrollState: androidx.wear.compose.material.ScalingLazyListState? =
        androidx.wear.compose.material.rememberScalingLazyListState(),
    properties: DialogProperties = DialogProperties(),
    content: @Composable () -> Unit,
)

Parameters

NameDescription
showDialogControls whether to display the Dialog. Set to true initially to trigger an 'intro' animation and display the Dialog. Subsequently, setting to false triggers an 'outro' animation, then Dialog calls onDismissRequest and hides itself.
onDismissRequestExecutes when the user dismisses the dialog. Must remove the dialog from the composition.
modifierModifier to be applied to the dialog.
scrollStateThe scroll state for the dialog so that the scroll position can be displayed.
propertiesTypically platform specific properties to further configure the dialog.
contentSlot for dialog content such as Alert or Confirmation