Compose Unstyled 2.0 is out! Check the official announcement blog ->

Checkbox controls for independent on and off selections.

Use checkboxes when people can enable or disable options independently.

View on GitHub
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import com.composables.ui.components.Checkbox
import com.composables.ui.components.Text

@Composable
fun CheckboxExample() {
    var checked by remember { mutableStateOf(true) }
    Checkbox(checked = checked, onCheckedChange = { checked = it }) {
        Text("Receive updates")
    }
}

Installation

implementation("com.composables:ui:0.1.0")

Examples

Disabled

View on GitHub
import androidx.compose.runtime.Composable
import com.composables.ui.components.Checkbox
import com.composables.ui.components.Text

@Composable
fun DisabledCheckboxExample() {
    Checkbox(checked = false, onCheckedChange = {}, enabled = false) {
        Text("Receive updates")
    }
}

Hierarchical selection

For parent and child selection flows, use the tri-state checkbox variant.

See Tri-State Checkbox.

API Reference

Checkbox

A checkbox for independent binary selections.

@Composable
fun Checkbox(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    accessibilityLabel: String? = null,
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
    content: (@Composable RowScope.() -> Unit)? = null,
)
Parameter Type Description
checked Boolean Whether the checkbox is currently checked.
onCheckedChange (Boolean) -> Unit Called when the checked state changes.
modifier Modifier Modifier applied to the checkbox row.
enabled Boolean Whether the checkbox can be interacted with.
accessibilityLabel String? Accessible label announced for the checkbox.
interactionSource MutableInteractionSource Interaction source used for focus and press state.
content (@Composable RowScope.() -> Unit)? Optional label or supporting content displayed next to the checkbox.