Skip to main content

CamoSwitch

An on/off switch that applies immediately (Wi-Fi on), announced as "Wi-Fi, switch, on". With a label the whole row is one target. The thumb can be dragged: released past the middle it toggles, otherwise it springs back. A null onCheckedChange makes it display-only.

Usage​

var notifications by remember { mutableStateOf(true) }

CamoSwitch(
checked = notifications,
onCheckedChange = { notifications = it },
label = "Notifications",
description = "Uses more battery",
)

API​

public fun CamoSwitch(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
label: String? = null,
labelSpans: List<CamoSpan>? = null,
description: String? = null,
error: String? = null,
enabled: Boolean = true,
interactionSource: MutableInteractionSource? = null,
)
NameTypeDefault
checkedBooleanrequired
onCheckedChange((Boolean) -> Unit)?
modifierModifierModifier
labelString?null
labelSpansList<CamoSpan>?null
descriptionString?null
errorString?null
enabledBooleantrue
interactionSourceMutableInteractionSource?null
Design notes

Why CamoSwitch works this way, its states and its edge cases: contributor docs.