SwitchLabelled

fun SwitchLabelled(checked: Boolean, onCheckedChange: (Boolean) -> Unit?, modifier: Modifier = Modifier, enabled: Boolean = true, intent: ToggleIntent = ToggleIntent.Basic, icons: SwitchIcons? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, contentSide: ContentSide = ContentSide.Start, content: @Composable RowScope.() -> Unit)

Switches are the preferred way to adjust settings. They're used to control binary options – think On/Off or True/False.

  • Toggle a single item on or off.

  • Immediately activate or deactivate something.

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 the layout of the 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

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.

contentSide

The side where we want to show the label, default to ContentSide.Start.

content

The content displayed before the switch, usually a Text composable shown at the start.

See also

if you require color customization between states. Be aware that this is still an internal composable so if you need such state contact the Spark team