OudsSwitch

fun OudsSwitch(checked: Boolean, onCheckedChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, interactionSource: MutableInteractionSource? = null)

OUDS Switch design guidelines

Switches allow the user to toggle between two states, typically "on" and "off". It is represented as a slider that changes its position or color to indicate the current state. Switches are used to enable or disable features, options, or settings in an intuitive and visual manner.

The standalone switch variant can be used when the switch selector control is nested within another component and an alternative label is provided.

Parameters

checked

Controls checked state of the switch.

onCheckedChange

Callback invoked on switch click. If null, then this is passive and relies entirely on a higher-level component to control the checked state.

modifier

Modifier applied to the layout of the switch.

enabled

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

interactionSource

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

See also

If you want to use a switch 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 com.orange.ouds.core.component.OudsSwitch

fun main() { 
   //sampleStart 
   var checked by remember { mutableStateOf(false) }

OudsSwitch(
    checked = checked,
    onCheckedChange = { value -> checked = value }
) 
   //sampleEnd
}