[Jetpack Compose] ラジオボタンを表示する

実装

@Composable
private fun MyRadioButton() {
    val radioOptions = listOf(
        "Option1",
        "Option2",
        "Option3",
        "Option4",
        "Option5",
        "Option6",
    )
    var selectedOption by remember { mutableStateOf(radioOptions[0]) }

    Column(
        modifier = Modifier
            .fillMaxSize(),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        radioOptions.forEach { text ->
            Row(
                Modifier.selectable(
                    selected = (text == selectedOption),
                    onClick = {
                        selectedOption = text
                    })
            ) {
                RadioButton(
                    selected = (text == selectedOption),
                    onClick = null
                )
                Text(
                    text = text
                )
            }
            Spacer(modifier = Modifier.height(44.dp))
        }
    }
}