OudsTriStateCheckboxItem
OUDS Checkbox design guidelines
An OUDS checkbox parent item. It is a layout containing an com.orange.ouds.core.component.OudsTriStateCheckbox, an associated text and several other optional elements which is often used in a list to handle checkbox items hierarchy. By clicking on a checkbox parent item, the user changes the checked state of its checkbox.
If you only need a standalone parent checkbox, please use com.orange.ouds.core.component.OudsTriStateCheckbox.
If you don't need an indeterminate state for the item's checkbox, you may prefer OudsCheckboxItem.
Parameters
Controls whether item's TriStateCheckbox is checked, unchecked or in indeterminate state.
The main text of the checkbox item.
Callback invoked when checkbox item is being clicked, therefore the change of checkbox ToggleableState state is requested. If null, then this is passive and relies entirely on a higher-level component to control the state.
Modifier applied to the layout of the checkbox item.
Optional text displayed below the main text.
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 checkbox item.
When false
, the checkbox has a leading position and the optional icon has a trailing position. It is inverted otherwise.
Controls the enabled state of the checkbox item. When false
, the checkbox, the text and the optional icon are disabled, and the item will not be clickable.
Controls the read only state of the checkbox item. When true
the item's checkbox 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 checkbox item will be displayed in disabled state.
Controls the error state of the checkbox item.
Optional hoisted MutableInteractionSource for observing and emitting Interactions for the item's checkbox. Note that if null
is provided, interactions will still happen internally.
Samples
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.state.ToggleableState
import com.orange.ouds.core.component.OudsCheckboxItem
import com.orange.ouds.core.component.OudsTriStateCheckboxItem
fun main() {
//sampleStart
var toggleableState by remember { mutableStateOf(ToggleableState.Off) }
OudsTriStateCheckboxItem(
state = toggleableState,
text = "My hobbies",
helperText = "Select the hobbies you practice regularly.",
onClick = {
toggleableState = when (toggleableState) {
ToggleableState.On -> ToggleableState.Off
ToggleableState.Off -> ToggleableState.Indeterminate
ToggleableState.Indeterminate -> ToggleableState.On
}
}
)
//sampleEnd
}