AlertDialog
In Material 3 Compose
@Composable
fun RadioButtonSample() {
// We have two radio buttons and only one can be selected
var state by rememberSaveable { mutableStateOf(true) }
// Note that Modifier.selectableGroup() is essential to ensure correct accessibility behavior.
// We also set a content description for this sample, but note that a RadioButton would usually
// be part of a higher level component, such as a raw with text, and that component would need
// to provide an appropriate content description. See RadioGroupSample.
Row(Modifier.selectableGroup()) {
RadioButton(
selected = state,
onClick = { state = true },
modifier = Modifier.semantics { contentDescription = "Localized Description" },
)
RadioButton(
selected = !state,
onClick = { state = false },
modifier = Modifier.semantics { contentDescription = "Localized Description" },
)
}
}