OudsSwitch
fun OudsSwitch(checked: Boolean, onCheckedChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, interactionSource: MutableInteractionSource? = null)
OUDS Checkbox design guidelines // TODO Replace with switch URL when it is available
An OUDS switch.
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.
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
}