Skip to content

Checkbox ​

A tri-state box for boolean or mixed selection — checked, indeterminate, or off. Use it for individual opt-ins or for a "select all" control whose indeterminate state reflects a partial child selection.

Import ​

kotlin
import io.github.heartcoolman.prism.ui.PrismCheckbox

Basic usage ​

kotlin
var checked by remember { mutableStateOf(false) }

PrismCheckbox(
    checked = checked,
    onCheckedChange = { checked = it },
)

With a label ​

When label is set, the whole row becomes toggleable and the box is rendered as presentational.

kotlin
var checked by remember { mutableStateOf(true) }

PrismCheckbox(
    checked = checked,
    onCheckedChange = { checked = it },
    label = "Checkbox",
)

Indeterminate ​

indeterminate takes precedence over checked and renders the dash. Toggling still reports !checked.

kotlin
PrismCheckbox(
    checked = false,
    onCheckedChange = {},
    indeterminate = true,
    label = "Select all",
)

API ​

ParameterTypeDefaultDescription
checkedBoolean—Whether the box is checked.
onCheckedChange(Boolean) -> Unit—Fired with !checked when toggled.
modifierModifierModifierModifier applied to the box (or the row when label is set).
enabledBooleantrueWhether the control accepts input.
indeterminateBooleanfalseRenders the mixed-state dash; takes precedence over checked.
labelString?nullOptional text beside the box; makes the whole row toggleable.

Assumes an enclosing PrismTheme { }. The checked fill is PrismTheme.colors.accent.

Released under the MIT License.