OudsRadioButtonItem

fun OudsRadioButtonItem(selected: Boolean, label: String, onClick: () -> Unit?, modifier: Modifier = Modifier, additionalLabel: String? = null, helperText: String? = null, icon: OudsControlItem.Icon? = null, divider: Boolean = false, outlined: Boolean = false, reversed: Boolean = false, enabled: Boolean = true, readOnly: Boolean = false, 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 radio button item variant can function as a simple input with a label in a selection group, or it can be combined with optional elements such as additional label, helper text, a divider, or an icon, allowing it to suit various use cases.

The OUDS radio button item layout contains an OudsRadioButton. By clicking on the radio button item, the user changes the selected state of its radio button.

In most cases, OUDS radio button items span the entire width of the screen. Thus an horizontal padding of OudsTheme.grids.margin is applied to the content. This behaviour can be disabled by calling com.orange.ouds.core.utilities.edgeToEdgePadding modifier with enabled parameter set to false.

Parameters

selected

Controls selected state of the radio button.

label

The main label of the radio button item.

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 item.

additionalLabel

Optional strong accompanying label for the main label. It is displayed between the label and the helperText.

helperText

Optional text displayed below the label and the additionalLabel.

icon

Optional icon displayed in the item. By default, it has a trailing position. If reversed is set to true, it is displayed as a leading element.

divider

Controls the display of a divider at the bottom of the radio button item.

outlined

When set to true, the radio button item, if selected, is outlined to stand out and draw the user's attention.

reversed

When false, the radio button has a leading position and the optional icon has a trailing position. Otherwise, it is reversed.

enabled

Controls the enabled state of the radio button item. When false, the radio button, the texts and the optional icon are disabled, and the item will not be clickable.

readOnly

Controls the read only state of the radio button item. When true the item's radio button is disabled but the texts 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.

error

Controls the error state of the radio button item.

interactionSource

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.

See also

If you want to use a standalone radio button.

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,
            label = gender,
            onClick = { selectedGender = gender },
            divider = true
        )
    }
} 
   //sampleEnd
}