Compose Unstyled 2.0 is out! Check the official announcement blog ->

Radio Group

Single-selection radio groups with individually selectable options.

Use radio groups when exactly one option should be selected from a set.

View on GitHub
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.unit.dp
import com.composables.ui.components.Radio
import com.composables.ui.components.RadioGroup
import com.composables.ui.components.Text

@Composable
fun RadioGroupExample() {
    var selected by remember { mutableStateOf("Weekly") }
    RadioGroup(value = selected, onValueChange = { selected = it }) {
        Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
            Radio("Daily") { Text("Daily") }
            Radio("Weekly") { Text("Weekly") }
            Radio("Monthly") { Text("Monthly") }
        }
    }
}

Installation

implementation("com.composables:ui:0.1.0")

Examples

Disabled

View on GitHub
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
import com.composables.ui.components.Radio
import com.composables.ui.components.RadioGroup
import com.composables.ui.components.Text

@Composable
fun DisabledRadioGroupExample() {
    val selected = "Daily"
    RadioGroup(value = selected, onValueChange = {}) {
        Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
            Radio("Daily") { Text("Daily") }
            Radio("Weekly", enabled = false) { Text("Weekly") }
            Radio("Monthly", enabled = false) { Text("Monthly") }
        }
    }
}

API Reference

RadioGroup

A single-selection group that coordinates radio options.

@Composable
fun <T> RadioGroup(
    value: T?,
    onValueChange: (T) -> Unit,
    modifier: Modifier = Modifier,
    accessibilityLabel: String? = null,
    content: @Composable () -> Unit,
)
Parameter Type Description
value T? Currently selected value for the radio group or the value represented by a radio.
onValueChange (T) -> Unit Called when the selected value changes.
modifier Modifier Modifier applied to the component.
accessibilityLabel String? Accessible label announced for the radio group.
content @Composable () -> Unit Composable content displayed by the component.

Radio

A selectable option inside a RadioGroup.

@Composable
fun <T> Radio(
    value: T,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    content: (@Composable RowScope.() -> Unit)? = null,
)
Parameter Type Description
value T Currently selected value for the radio group or the value represented by a radio.
modifier Modifier Modifier applied to the component.
enabled Boolean Whether the radio option can be interacted with.
interactionSource MutableInteractionSource Interaction source used for focus and press state.
content (@Composable RowScope.() -> Unit)? Composable content displayed by the component.