OudsTriStateCheckbox

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

OUDS Checkbox design guidelines

Checkboxes are input controls that allow users to select one or more options from a number of choices.

This checkbox supports the indeterminate state: Checkboxes can have a parent-child relationship with other checkboxes. When the parent checkbox is checked, all child checkboxes are checked. If a parent checkbox is unchecked, all child checkboxes are unchecked. If some, but not all, child checkboxes are checked, the parent checkbox becomes an indeterminate checkbox.

The indeterminate standalone checkbox variant allows to manage a checkbox with an indeterminate state that can be used when the checkbox input is nested within another component and an alternative label is provided.

Parameters

state

Controls whether TriStateCheckbox is checked, unchecked or in indeterminate state.

onClick

Callback invoked when checkbox is being clicked, therefore the change of ToggleableState state is requested. If null, then this is passive and relies entirely on a higher-level component to control the state.

modifier

Modifier applied to the layout of the checkbox.

enabled

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

error

Controls the error state of the checkbox.

interactionSource

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

See also

If you need a simple component that represents Boolean state.

If you want to use an indeterminate checkbox with an associated label and other optional elements.

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.OudsCheckbox
import com.orange.ouds.core.component.OudsTriStateCheckbox

fun main() { 
   //sampleStart 
   var toggleableState by remember { mutableStateOf(ToggleableState.Off) }

OudsTriStateCheckbox(
    state = toggleableState,
    onClick = {
        toggleableState = when (toggleableState) {
            ToggleableState.On -> ToggleableState.Off
            ToggleableState.Off -> ToggleableState.Indeterminate
            ToggleableState.Indeterminate -> ToggleableState.On
        }
    }
) 
   //sampleEnd
}