androidx.compose.material3

BasicAlertDialogExperimental

Composable function

One of the dialog types. It works like AlertDialog. Only the parameters that differ are described here.

An empty dialog window. You build the inside yourself, usually a Surface with your layout.

A basic dialog with your own layout
A basic dialog with your own layout
// The Box only gives the picture a size. In an app, show the dialog when a state is true.
Box(Modifier.size(360.dp, 300.dp)) {
    BasicAlertDialog(onDismissRequest = {}) {
        Surface(shape = MaterialTheme.shapes.large, tonalElevation = AlertDialogDefaults.TonalElevation) {
            Column(Modifier.padding(24.dp)) {
                Text("Wi-Fi is off. Some photos may not load until you connect.")
                Spacer(Modifier.height(24.dp))
                TextButton(onClick = {}, modifier = Modifier.align(Alignment.End)) { Text("OK") }
            }
        }
    }
}

ParametersExperimental

@Composable
fun BasicAlertDialog(
    onDismissRequest: () -> Unit,
    modifier: Modifier = Modifier,
    properties: DialogProperties = DialogProperties(),
    content: @Composable () -> Unit,
)

Same as in AlertDialog: onDismissRequest, modifier, properties, content.

Dialog types

See also