OudsRadioButton
fun OudsRadioButton(selected: Boolean, onClick: () -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, error: Boolean = false, interactionSource: MutableInteractionSource? = null)
OUDS Radio button design guidelines
An OUDS radio button.
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.
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
}