OudsRadioButtonItem
OUDS Radio button design guidelines
An OUDS radio button item is a layout containing an OudsRadioButton, an associated text and several other optional elements. It can be used in a list as a list item. By clicking on a radio button item, the user changes the selected state of its radio button.
If you want to use a standalone radio button please use com.orange.ouds.core.component.OudsRadioButton.
Parameters
Controls selected state of the radio button.
The main text of the radio button item.
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 applied to the layout of the radio button item.
Optional strong accompanying text for the main label. It is displayed between the text and the helperText.
Optional text displayed below the text and the additionalText.
Optional icon displayed in the item. By default, it has a trailing position. If inverted is set to true
, it is displayed as a leading element.
Controls the display of a divider at the bottom of the radio button item.
When set to true
, the radio button item, if selected, is outlined to stand out and draw the user's attention.
When false
, the radio button has a leading position and the optional icon has a trailing position. It is inverted otherwise.
Controls the enabled state of the radio button item. When false
, the radio button, the text and the optional icon are disabled, and the item will not be clickable.
Controls the read only state of the radio button item. When true
the item's radio button is disabled but the text and the icon remain in enabled color. Note that if it is set to true
and enabled is set to false
, the radio button item will be displayed in disabled state.
Controls the error state of the radio button item.
Optional hoisted MutableInteractionSource for observing and emitting Interactions for the item's 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.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.orange.ouds.core.component.OudsRadioButtonItem
fun main() {
//sampleStart
val genders = listOf("Female", "Male", "Other")
var selectedGender by rememberSaveable { mutableStateOf(genders.first()) }
Column(modifier = Modifier.selectableGroup()) {
genders.forEach { gender ->
OudsRadioButtonItem(
selected = gender == selectedGender,
text = gender,
onClick = { selectedGender = gender },
divider = true
)
}
}
//sampleEnd
}