Radio button

Lets people choose exactly one option from a short list.

When to use

Use radio buttons when all options should be visible at once and only one can apply. For long lists use a menu, and for two options consider a switch.

Wrap the group in Modifier.selectableGroup and make each row selectable with Role.RadioButton.

Playground

The interactive page has a playground with live property controls for this component and generated code.

Examples

Group

val options = listOf("Small", "Medium", "Large")
var selected by rememberSaveable { mutableIntStateOf(1) }

Column(Modifier.selectableGroup()) {
    options.forEachIndexed { index, label ->
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .selectable(
                    selected = selected == index,
                    onClick = { selected = index },
                    role = Role.RadioButton,
                ),
            verticalAlignment = Alignment.CenterVertically,
        ) {
            RadioButton(selected = selected == index, onClick = null)
            Text(label)
        }
    }
}

Parameters

NameTypeDefaultDescription
selectedBooleanWhether this option is selected.
onClick(() -> Unit)?Pass null when the row handles the click.
colorsRadioButtonColorsRadioButtonDefaults.colors()Selected and unselected colors.

Guidelines

Do:

Don't:

Accessibility

Related components