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
- Kotlin
- Dart
var notifications by remember { mutableStateOf(true) }
CamoSwitch(
checked = notifications,
onCheckedChange = { notifications = it },
label = "Notifications",
description = "Uses more battery",
)
API
- Kotlin
- Dart
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,
)
| Name | Type | Default |
|---|---|---|
checked | Boolean | required |
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 |
Design notes
Why CamoSwitch works this way, its states and its edge cases: contributor docs.