Switch

fun Switch(checked: Boolean, onCheckedChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, intent: ToggleIntent = ToggleIntent.Basic, icons: SwitchIcons? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() })

Switch component allows the user to activate or deactivate the state of an element or concept. It is usually used as an element to add services, activate functionalities or adjust settings. It is also used to control binary options (On/Off or True/False).

Parameters

checked

whether or not this component is checked

onCheckedChange

callback to be invoked when Switch is being clicked, therefore the change of checked state is requested. If null, then this is passive and relies entirely on a higher-level component to control the "checked" state.

modifier

Modifier to be applied to switch layout

enabled

whether the component is enabled or grayed out

intent

The ToggleIntent to use to draw the component

icons

represents the pair of icons to use for check/unchecked states, you can use SwitchDefaults.icons if you want to use the default ones.

interactionSource

the MutableInteractionSource representing the stream of Interactions for this Switch. You can create and pass in your own remembered MutableInteractionSource if you want to observe Interactions and customize the appearance / behavior of this Switch in different Interactions.