Checkbox
Functions summary
Unit |
@Composable
|
Functions
Checkbox
@Composable
fun Checkbox(
checked: Boolean,
modifier: Modifier = Modifier,
colors: CheckboxColors = CheckboxDefaults.colors(),
enabled: Boolean = true,
onCheckedChange: ((Boolean) -> Unit)? = null,
interactionSource: MutableInteractionSource? = null
): Unit
Checkbox provides an animated checkbox for use as a toggle control in ToggleChip or SplitToggleChip.
Example of a SplitToggleChip with Checkbox toggle control:
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.text.style.TextOverflow import androidx.wear.compose.material.Checkbox import androidx.wear.compose.material.Icon import androidx.wear.compose.material.SplitToggleChip import androidx.wear.compose.material.Text import androidx.wear.compose.material.ToggleChip var checked by remember { mutableStateOf(true) } // The primary label should have a maximum 3 lines of text // and the secondary label should have max 2 lines of text. SplitToggleChip( label = { Text("Split with CheckboxIcon", maxLines = 3, overflow = TextOverflow.Ellipsis) }, checked = checked, toggleControl = { Checkbox(checked = checked, enabled = true) }, onCheckedChange = { checked = it }, onClick = { /* Do something */ }, enabled = true, )
| Parameters | |
|---|---|
checked: Boolean |
Boolean flag indicating whether this checkbox is currently checked. |
modifier: Modifier = Modifier |
Modifier to be applied to the checkbox. This can be used to provide a content description for accessibility. |
colors: CheckboxColors = CheckboxDefaults.colors() |
|
enabled: Boolean = true |
Boolean flag indicating the enabled state of the |
onCheckedChange: ((Boolean) -> Unit)? = null |
Callback to be invoked when Checkbox is clicked. If null, then this is passive and relies entirely on a higher-level component to control the state (such as |
interactionSource: MutableInteractionSource? = null |
When also providing |