OudsRadioButton

fun OudsRadioButton(selected: Boolean, onClick: () -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, error: Boolean = false, interactionSource: MutableInteractionSource? = null)

OUDS Radio button design guidelines

Radio buttons are input controls that allow users to select a single option from a set of mutually exclusive choices.

The standalone radio button variant can be used when the radio selector control is nested within another component and an alternative label is provided.

Parameters

selected

Controls the selected state of the radio button.

onClick

Callback invoked on radio button click. If null, then this radio button will not be interactable, unless something else handles its input events and updates its state.

modifier

Modifier applied to the layout of the radio button.

enabled

Controls the enabled state of the radio button. When false, this radio button will not be clickable.

error

Controls the error state of the radio button.

interactionSource

Optional hoisted MutableInteractionSource for observing and emitting Interactions for this radio button. Note that if null is provided, interactions will still happen internally.

See also

If you want to use a radio button with an associated label and other optional elements.

Samples

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.orange.ouds.core.component.OudsRadioButton

fun main() { 
   //sampleStart 
   val identifiers = listOf(0, 1)
var selectedId by rememberSaveable { mutableIntStateOf(identifiers.first()) }

Column(modifier = Modifier.selectableGroup()) {
    identifiers.forEach { id ->
        OudsRadioButton(
            selected = id == selectedId,
            onClick = { selectedId = id }
        )
    }
} 
   //sampleEnd
}