Skip to content

Instantly share code, notes, and snippets.

@aritra-tech
Created May 9, 2024 15:09
Show Gist options
  • Save aritra-tech/db5b32758d01a702143b431e3e40f5ca to your computer and use it in GitHub Desktop.
Save aritra-tech/db5b32758d01a702143b431e3e40f5ca to your computer and use it in GitHub Desktop.
@Composable
fun ToggleChipExample() {
var checked by remember { mutableStateOf(true) }
ToggleChip(
modifier = Modifier.fillMaxWidth(),
label = {
Text("Dark Mode")
},
checked = checked,
colors = ToggleChipDefaults.toggleChipColors(
uncheckedToggleControlColor = ToggleChipDefaults.SwitchUncheckedIconColor
),
toggleControl = {
Switch(
checked = checked,
enabled = true,
modifier = Modifier.semantics {
this.contentDescription =
if (checked) "On" else "Off"
}
)
},
onCheckedChange = { checked = it },
enabled = true,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment