# RadioButton

> RadioButton from Material 3 Compose (`androidx.compose.material3:material3`) for Jetpack Compose, with a code sample.

- Library: [Material 3 Compose](https://composables.com/material-components/material-3-compose.md)
- Category: [Buttons](https://composables.com/material-components/buttons.md)
- Category: [Radio Buttons](https://composables.com/material-components/radio-buttons.md)
- API reference and more examples: [RadioButton](https://composables.com/jetpack-compose/androidx.compose.material3/material3/components/RadioButton/api.md)

## Code

```kotlin
@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" },
        )
    }
}
```
